Compiler not recognizing numbers

Hello!

I'm working on this homework assignment where the program takes in the user's height in inches, weight in pounds, and age, then calculates their hat size, jacket size and waist size. The formulas for these are as follows:

Hat: (weight/height) x 2.9
Jacket: (height x weight)/288 then adjusted by adding 1/8 an inch for every 10 years over the age of 30 (The adjustment only takes place after a full 10 years, so there is no adjustment for 30-39, but there is for 40)
Waist: (weight/5.7) then adjusted by adding 1/10 of an inch for each 2 years over the age of 28 (the adjustment only takes place after a full 2 years, so no adjustment for 29, but there is for 30, etc)

I'm supposed to utilize functions for each of the three formulas.

There's a couple things I can't figure out.
1. Why won't the compiler recognize 2.9 and 5.7 as numbers?
2. How do I adjust the calculation for the jacket and waist based on age?

Here's what I've got so far:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <cstdlib>
#include <iostream>
using namespace std;

double hatSize(int weight, int height);
double jacketSize(int weight, int height, int age);
double waistSize(int weight, int height, int age);

int main(int argc, char *argv[])
{
    int userWeight, userHeight, userAge;
    double hatResult, jacketResult, waistResult;
    
    cout<<"How tall are you in inches? ";
    cin>>userHeight;
    cout<<"How much do you weigh in pounds? ";
    cin>>userWeight;
    cout<<"How old are you? ";
    cin>>userAge;
    
    hatResult = hatSize(userWeight, userHeight);
    jacketResult = jacketSize(userWeight, userHeight, userAge);
    waistResult = waistSize(userWeight, userHeight, userAge);
    
    cout.setf(ios::fixed);
         cout.setf(ios::showpoint);
         cout.precision(2);
         cout<<"\nYour hat size is "<< hatResult <<"!\n"; //output number 1!
    cout.setf(ios::fixed);
         cout.setf(ios::showpoint);
         cout.precision(2);
         cout<<"Your jacket size is "<< jacketResult <<"!\n"; //output number 2!
    cout.setf(ios::fixed);
         cout.setf(ios::showpoint);
         cout.precision(2);
         cout<<"Your waist size is "<< waistResult <<"!\n"; //output number 3!
    
    
    system("PAUSE");
    return EXIT_SUCCESS;
}

double hatSize(int weight, int height)
{
       const double a = 2.9; //why won't it recognize this as 2.9?
       double b = (weight/height);
       return (b * a);
}
double jacketSize(int weight, int height, int age)
{
       const double a = 288;
       double b = (height * weight);
       double c = (b/a);
       if (age >= 40)
       {
            age += 10;
            c = (c + .80);
       }
       return c;
}
double waistSize(int weight, int height, int age)
{
       const double a = 5.7;
       double b = (weight/a);
       if (age >= 28)
       {
            age += 2;   
            b = (b + .10);
       }
       return b;
}


Please help!
> Why won't the compiler recognize 2.9 and 5.7 as numbers?
I don't understand what you mean, ¿how did you diagnosticate that issue?

By the way, integer division returns an integer
Topic archived. No new replies allowed.