mengira BMI (ain, niesa, kiah)

Go down

mengira BMI (ain, niesa, kiah)

Post  ~ni[E]sa69~ on Wed Dec 09, 2009 12:09 am

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;
 
}
avatar
~ni[E]sa69~

Number of posts : 3
Age : 28
Registration date : 2009-08-05

View user profile

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum