hi,right now my program to calculate bmi for male female ,athlete female and athlete male..i have have some problem,i don't know how to matching else if..can anyone help me...
#include<iostream>
#include<iomanip>
#include<math.h>
#include <cmath>
void Metre();
double cmi_b(double, double);
using namespace std;
int num[]= {25,30};
double number[]= {19.1, 25.8, 32.8, 37};
int main()
{
char gender;char athlete;
cout <<"Please enter your gender. M or F"<<endl;
cin>>gender;
if ((gender == 'F')||(gender =='f'))//cannot matching with else
cout <<"Are you athlete? Y or N"<<endl;
cin>>athlete;
{
if ((athlete == 'N')||(athlete =='n'))
{
float weight;
float height;
char response;
float bmi;
do
{
cout << "*****************************\n";
cout << "Please enter your weight (kg): ";
cin >> weight;
cout << "Please enter your height (m): ";
cin >> height;
bmi = weight/(height*height);
cout<<"\n";
cout<<"Your BMI is " << bmi << endl;
if (bmi < 18.5)
{
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (bmi >= 18.5 && bmi <25)
{
cout << "You are normal!"<<endl;
cout << "You are cool!"<<endl;
}
else if (bmi >= 25 && bmi <30)
{
cout << "You are overweight!"<<endl;
cout << "You should diet!"<<endl;
}
else if (bmi >= 30)
{
cout << "You are obesity!"<<endl;
cout << "You should do more exercise!"<<endl;
}
else
cout << endl;
cout << "Would you like to enter the information again? ";
cin >> response;
}
while (toupper(response) == 'Y');
cout << "Okay, see you next time.." << endl;
return 0;
}
else if ((athlete =='Y')||(athlete =='y'))
{
float weight;
float height;
char response;
float bmi;
do
{
cout << "*****************************\n";
cout << "Please enter your weight (kg): ";
cin >> weight;
cout << "Please enter your height (m): ";
cin >> height;
bmi = weight/(height*height);
cout<<"\n";
cout<<"Your BMI is " << bmi << endl;
if (bmi < 19.1)
{
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (bmi >= number[0] && bmi <num[0])
{
cout << "You are normal!"<<endl;
cout << "You are cool!"<<endl;
}
else if (bmi >= num[0] && bmi <num[1])
{
cout << "You are overweight!"<<endl;
cout << "You should diet!"<<endl;
}
else if (bmi >= num[1])
{
cout << "You are obesity!"<<endl;
cout << "You should do more exercise!"<<endl;
}
else
cout << endl;
cout << "Would you like to enter the information again? ";
cin >> response;
}
while (toupper(response) == 'Y');
cout << "Okay, see you next time.." << endl;
return 0;
}
}
else if ((gender =='M')||(gender == 'm'))//this else
{
Metre();
return 0;
}
else
return 0;
}
void Metre()
{
double height_m, weight_kg, cmi_a;
cout << "Please enter your height in metre :\n";
cin >> height_m;
cout << "Please enter your weight in kilograms :\n";
cin >> weight_kg;
cmi_a = cmi_b(weight_kg, height_m);
cout << "Your BMI is " << cmi_a << ".\n";
if (cmi_a <19.1)
{
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (cmi_a >=19.1 && cmi_a <25.8)
{
cout << "You are normal!"<<endl;
cout << "You are cool!"<<endl;
}
else if (cmi_a >= 25.8 && cmi_a <32.2)
{
cout << "You are overweight!"<<endl;
cout << "You should diet!"<<endl;
}
else if (cmi_a >= 32.2)
{
cout << "You are obesity!"<<endl;
cout << "You should do more exercise!"<<endl;
}
else
cout << endl;
cout << "Thank you.\n";
}
double cmi_b (double w, double h)
{
double final_cmi;
final_cmi = (w /(h*h));
return final_cmi;
}