Error Help.

Here's the instructions:
Write a program that asks for the user's height, weight, and age and then computers the clothing sizes according to the formulas:

-Hat size = weight in pounds divided by the height in inches and all mutiplied by 2.9

- Jacket size ( chest in inches) = height times weight divided by 288 and then adjusted by adding 1/8 on an inch for each 10 years over age 30 ( Note that the adjustment only takes place after a full 10 years, So there is no adjustment for ages 30 through 39, bey 1/8 of an inch is added for the age 40 )

- Waist in inches = weight divided by 5.7 and then adjusted by adding 1/10 of an inch for each 2 years over age 28 ( Note that the adjustment only takes place after a full 2 years. So, there is no adjustment for ages 29, but 1/10 of an inch is added for age 30 )

Use functions for each calculation. Your program should allow the user to repeat the calculation as often as the user wishes.

My program
#include <iostream>
using namespace std;
double hatsize(double weight, double height);
double jacketsize(double weight, double height, int age);
double waistsize(double weight, int age);

int main()
{
double weight, height, hatsize, jacketsize, waistsize;
int age;
cout << "Please type in your height, weight and age IN THAT ORDER." << endl;
cin >> height >> weight >> age;
cout << "Hat size ="<<hatsize(weight,height)<< endl;
cout << "Jacket size ="<<jacketsize(weight, height, age)<< endl;
cout << "Waist Size ="<<waistsize(weight, age)<< endl;
return 0;
}
double hatsize(double weight, double height)
{
return ((weight/height)*2.9);
}
double jacketsize(double weight, double height, int age)
{
if(age<40)
jacketsize=((height*weight)/288);
else if(age>=40 && age<50)
jacketsize=(((height*weight)/288)+(1/8));
else if(age>=50 && age<60)
jacketsize=(((height*weight)/288)+(1/4));
else if(age>=60 && age<70)
jacketsize=(((height*weight)/288)+(3/8));
else if(age>=70 && age<80)
jacketsize=(((height*weight)/288)+(1/2));
else if(age>=80 && age<90)
jacketsize=(((height*weight)/288)+(5/8));
else if(age>=90 && age<100)
jacketsize=(((height*weight)/288)+(3/4));
else if(age>=100 && age<110)
jacketsize=(((height*weight)/288)+(7/8));
return jacketsize;
}
double waistsize(double weight, int age)
{
if(age<30)
waistsize = weight/5.7;
else
waistsize=(weight / 5.7) + ((1.0/10.0) * ((age - 30) / 2 ));
return waistsize;
}


when i run im getting error: binary not found first off and its marking a bunch of errors on the cout<< hat size/jacket/waist size in the intmain for the endl being overloaded and saying they cant be used as functions.

the other problem is in my long line of else ifs in the jacketsize function they are marked saying cant convert double to double.

sorry if its alot, im brand new to c++.

EDIT: here's the exact errors:
..\src\4.9 Programming Project.cpp:44: error: assignment of function `double jacketsize(double, double, int)'
..\src\4.9 Programming Project.cpp:44: error: cannot convert `double' to `double ()(double, double, int)' in assignment
..\src\4.9 Programming Project.cpp:45: error: cannot convert `double (*)(double, double, int)' to `double' in return
..\src\4.9 Programming Project.cpp: In function `double waistsize(double, int)':
..\src\4.9 Programming Project.cpp:50: error: assignment of function `double waistsize(double, int)'
..\src\4.9 Programming Project.cpp:50: error: cannot convert `double' to `double ()(double, int)' in assignment
..\src\4.9 Programming Project.cpp:52: error: assignment of function `double waistsize(double, int)'
..\src\4.9 Programming Project.cpp:52: error: cannot convert `double' to `double ()(double, int)' in assignment
..\src\4.9 Programming Project.cpp:53: error: cannot convert `double (*)(double, int)' to `double' in return
Last edited on
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
double jacketsize(double weight, double height, int age)
{
if(age<40)
jacketsize=((height*weight)/288);
else if(age>=40 && age<50)
jacketsize=(((height*weight)/288)+(1/8));
else if(age>=50 && age<60)
jacketsize=(((height*weight)/288)+(1/4));
else if(age>=60 && age<70)
jacketsize=(((height*weight)/288)+(3/8));
else if(age>=70 && age<80)
jacketsize=(((height*weight)/288)+(1/2));
else if(age>=80 && age<90)
jacketsize=(((height*weight)/288)+(5/8));
else if(age>=90 && age<100)
jacketsize=(((height*weight)/288)+(3/4));
else if(age>=100 && age<110)
jacketsize=(((height*weight)/288)+(7/8));
return jacketsize;
}
double waistsize(double weight, int age)
{
if(age<30)
waistsize = weight/5.7;
else
waistsize=(weight / 5.7) + ((1.0/10.0) * ((age - 30) / 2 ));
return waistsize;
}


In both of these functions, you are using a variable name that is the same as that of your function and assigning it a value. Use a different variable name in the functions to get the information you need.

ex in jacketsize()

instead of jacketsize=((height*weight)/288); use a different variable instead of jacketsize
Topic archived. No new replies allowed.