Wednesday, May 7, 2014

C++ codeing for Calculate your health level (Weight and Height )

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
float hi,wi,bmi;
char an;
do{
cout<<"   Enter your weight in 'kg' (kilograms): ";
cin>>wi;
cout<<endl;
cout<<"   Enter your height in 'm' (meters): ";
cin>>hi;
cout<<endl;


//calculation
bmi=wi/pow(hi,2);
cout<<"   Your bmi is "<<bmi;
cout<<endl;
if(bmi<18.5)
{
cout<<"   You are underweight.";
cout<<endl;
}

else if(bmi==18.5)
{
cout<<"   You are near underweight.";
cout<<endl;
}

else if(18.5<bmi && bmi<24.9)
{
cout<<"   You are considered normal weight.";
cout<<endl;
}

else if(24.9<bmi && bmi<29.9)
{
cout<<"   You are overweight."<<endl;
cout<<"   You may wish to consult with your physician for medical help";
cout<<endl;
}

else if(bmi==29.9)
{
cout<<"   You are near obese."<<endl;
cout<<"   You may wish to consult with your physician for medical help";
cout<<endl;
}

else if(30<bmi)
{
cout<<"   You are obese."<<endl;
cout<<"   You may wish to consult with your physician for medical help";
cout<<endl;
}
cout<<endl;
cout<<"   Do you wanna check onces more ?(Y/N)?";
cin>>an;
}while(an=='y'||an=='Y');

return 0;
}

No comments :

Post a Comment