新手求轻喷......
#include
using namespace std;
class People
{
public:
People(int i,float j);
~People(){}
float calculateBMI(int myWeight,float myHeight);
void getAnswer();
private:
int myWeight;
float myHeight,myBMI;
};
People::People(int i,float j)
{
myWeight=i;
myHeight=j;
}
float People::calculateBMI(int myWeight,float myHeight)
{
float myBMI;
myBMI=myWeight/(myHeight*myHeight);
return myBMI;
}
void People::getAnswer()
{
if(myBMI>=18.5&&myBMI<=23.9)
cout<<"No!"<<endl;
else
cout<<"Yes!"<<endl;
}
int main()
{
int myWeight;
float myHeight;
while(cin>>myWeight>>myHeight)
People x(int myWeight,float myHeight);
x.calculateBMI(myWeight,myHeight);
x.getAnswer();
return 0;
}