I need help with the calculation part of this program urgently i am new to c++

#include <iostream>
#include<string>

using namespace std;

int main()
{
//variables//
string Gender = "";
string Activitylevel = "";
double Weight = 0.0;
double Factivecalories = 0.0;
double Finactivecalories = 0.0;
double Mactivecalories = 0.0;
double Minactivecalories = 0.0;
int Fmoderatelyactive = 12.0;
int Frelativelyinactive = 10.0;
int Mmoderatelyactive = 15.0;
int Mrelativelyinactive = 13.0;

//user information//

cout<<"Are you a male or a female?\n";
cin >> Gender;
getline(cin, Gender);
cout<<"Are you relatively inactive or moderately active? \n";
cin >> Activitylevel;
getline(cin, Activitylevel);
cout<<"What is your weight?\n";
cin >> Weight;


//calculations//
if(Gender=="female"){ if(Activitylevel == "moderately acive"){
Factivecalories = Weight * Fmoderatelyactive;}
else {Finactivecalories = Weight * Frelativelyinactive;};
}

if(Gender == "male"){ if(Activitylevel == "moderately active"){
Mactivecalories = Weight * Mmoderatelyactive ;}
else {Minactivecalories = Weight * Mrelativelyinactive;}
}


//outputs on the screen//

if(Gender == "female"){ if(Activitylevel == "moderately acive"){
cout<<"Your total daily calories is:"<< Factivecalories << endl;
}
else {cout<<"Your total daily calories is:"<<Finactivecalories <<endl;}
}

if(Gender == "male"){ if(Activitylevel == "moderately acive"){
cout<<"Your total daily calories is:"<< Mactivecalories << endl;
}
else {cout<<"Your total daily calories is:"<<Minactivecalories <<endl;}
}




return 0;
}
Hi !
Use code tags please.
I notice that this early:
if(Gender == "male"){ if(Activitylevel == "moderately active"){

is not the same as this later:
if(Gender == "male"){ if(Activitylevel == "moderately acive"){

Though they should probably be merged or at least given a state so that u don't have to keep comparing the same strings.
Last edited on
Topic archived. No new replies allowed.