Can't find errors

These are the errors I am receiving. Not sure how to read them.


: In function ‘int main()’:
:42: error: expected ‘;’ before ‘{’ token
:53: error: ‘(((signed char)active_rate) == 104)’ cannot be used as a function



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
#include <iostream>
using namespace std; //included in every program
int main()


{
//Declare Variables

int height; //Height in inches (integer)
int age; //Age in years (integer)
double weight; //Weight in pounds (fractional part)
double bmr; //Basal Metabolic Rate (fractional part)
char gender; 
char active_rate; //Male or Female (one character or symbol)
double new_bmr;

//Input

cout<< "Enter your weight in pounds\n";
cin>> weight; //weight in pounds
cout<< "Enter your height in inches\n";
cin>> height; //height in inches
cout<< "Enter your age in years\n";
cin>> age;
cout<< "Enter s if you are sedentary, "
<< "w if you are somewhat active, "
<< "a if you are active, "
<< "or h if you are highly active.\n";
cin>> active_rate;
cout<< "Enter m or f\n";
cin>> gender; //male or female


//Processing data

if (gender == 'm') //m for male
{
bmr = 66 + (6.3 * weight) + (12.9 * height) - (6.8 * age);
//equation for men
}
else (gender == 'f') //f for female
{
bmr = 655 + (4.3 * weight) + (4.7 * height) - (4.7 * age);
}

if (active_rate == 's')
(new_bmr = bmr * 1.20);
else if (active_rate == 'w')
(new_bmr = bmr * 1.30);
else if (active_rate == 'a')
(new_bmr = bmr * 1.40);
else (active_rate == 'h')
(new_bmr = bmr * 1.50);


if ((gender == 'm')||(gender == 'f'))
if ((active_rate == 's')||(active_rate == 'a')||(active_rate == 'w')||(active_rate == 'h'))
{
cout<< "Your bmr is " << new_bmr << " calories"<<endl;
//total bmr in calories

cout<< "Number of chocalate bars is equal to "<< (new_bmr/230)<<endl;
cout<< "\nThe program is over\n";
//the program has ended
} 
else 
cout<< "Error: Please try again\n";

}
Last edited on
#1: [code]Put your code in code tags[/code]

#2: Don't paraphrase the errors. "Has to do with parenthesis I think" is not very informative. Post the actual error you're getting. I know the error message may seem like gibberish to you, but people here know how to read them.

#3: The error message will actually tell you exactly what line the error is on. Give us that line number. That makes it much easier to find the problem.
Okay hows that? thanks for the tip...
I got it to complie and work..hope this help :)

On like 41 you need a ; because that's syntax.

 
else (gender == 'f'); //f for female 


If I remember you only use else when you're assigning a default value with IF/ELSE. Instead you want to assign it based on "h" if that's why the user inputs.

1
2
3
4
5
if (active_rate == 's') (new_bmr = bmr * 1.20);
else if (active_rate == 'w')(new_bmr = bmr * 1.30);
else if (active_rate == 'a')(new_bmr = bmr * 1.40);
else if (active_rate == 'h')(new_bmr = bmr * 1.50);
Last edited on
Topic archived. No new replies allowed.