#include<iostream.h>
#include<conio.h>
#include<math.h>
int main()
{
//input
float age, weight, HeartBeatRate, CaloriesBurned, minutes;
char gender[3], name[41];
cout<<"Hello! I'm Calories Calculator from HealthDotCom. My job is to calculate your calories burned"<<endl;
cout<<"Let's get to know you"<<endl;
cout<<"Tell me your name"<<endl;
cin.getline(name,40);
cout<<"Please state your gender"<<endl;
cout<<"Female=F Male=M"<<endl;
cin.getline(gender,2);
cout<<"Now, please enter your age (in years)"<<endl;
cin>>age;
cout<<"Great! Now, please enter your weight (in kg)"<<endl;
cin>>weight;
cout<<"How long did you took to complete this exercise? (in minutes)"<<endl;
cin>>minutes;
cout<<"What is your average heart beat rate after you did this exercise? (per minute)"<<endl;
cin>>HeartBeatRate;
if (strcmp(gender, "female")==0)
{
CaloriesBurned= ((age*0.074) - weight*0.05741) + (((HeartBeatRate*0.4472)- 20.4022)*minutes/4.184);
cout<<"Age= "<<age<<endl;
cout<<"Weight= "<<weight<<endl;
cout<<"Heart Beat Rate (per minute)= "<<HeartBeatRate<<endl;
cout<<"Duration of exercise= "<<minutes<<endl;
cout<<"You have burned "<<CaloriesBurned<<"calories"<<endl;
}
else (gender, "male")==0) // this is where it says that i have a statement missing
{
CaloriesBurned= ((age*0.2017)- weight*0.09036)+(((HeartBeatRate*0.6309)- 55.0969)*minutes/4.184);
cout<<"Age= "<<age<<endl;
cout<<"Weight= "<<weight<<endl;
cout<<"Heart Beat Rate (per minute)= "<<HeartBeatRate<<endl;
cout<<"Duration of exercise (in minutes)= "<<minutes<<endl;
cout<<"The total calories burned for you is "<<CaloriesBurned<<endl;
}
cout<<"Congratulations, "<<name<<"! That is a great job!"<<endl;
cout<<"Keep it up!";
getch();
return 0;
}
and when i run the program after putting the semicolon there, the answer is wrong (logic error)
You really really need to learn to use some kind of indentation style. IMO your program is almost impossible to read without the indentation and the total lack of whitespace in your statements. https://en.wikipedia.org/wiki/Indent_style
You have several problems with your if/else statements.
First look at this snippet: if (gender == 'f' || 'F')
This is not how you use the logical operators in C++. You must have complete comparisons on both sides of the operator. if (gender == 'f' || gender == 'F')
You could alternatively just use toupper() or tolower() instead. if (tolower(gender) == 'f')
Next, look at this snippet: else (gender == 'm' || 'M')
The else statement stands on it's own, no comparisons are allowed.