mengira BMI (ain, niesa, kiah)
Page 1 of 1
mengira BMI (ain, niesa, kiah)
- Code:
#include<iostream>
using namespace std;
class data
{
protected:
double weight,height;
char name[20];
double bmi;
};
class BMI : public data
{
public:
void input()
{
cout<< "Enter Your Name: ";
cin>> name;
cout<< "Enter Your Weight In Kilogram: ";
cin>> weight;
cout<< "Enter Your Height In Centimetre: ";
cin>> height;
}
void kira()
{
height=height/100;
bmi=weight/(height*height);
cout<<"Your BMI: "<<bmi;
status(bmi);
}
void status(double bmi)
{
if(bmi <= 18.5)
{
cout<<"\nYour BMI indicates that your weight is under weight"<<endl;
}
else if (bmi>=18.5 && bmi<=24.99)
{
cout<<"\nYour BMI indicates that your weight is normal weight"<<endl;
}
else if(bmi >= 25 && bmi<=29.99)
{
cout<<"\nYour BMI indicates that your weight is overweight"<<endl;
}
else
{
cout<<"\nYour BMI indicates that your weight is obesity"<<endl;
}
}
};
int main()
{
BMI orang;
for(int i=0;i<4;i++)
{
orang.input();
orang.kira();
cout<<endl;
}
system("pause");
return 0;
}
~ni[E]sa69~- Number of posts : 3
Age : 33
Registration date : 2009-08-05
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|