#include <iostream>
using namespace std;
class standardWeight
{
private:
double height, weight;
int WeightStatus;
public:
void setHeight(const double h);
void setWeight(const double w);
double getHeight();
double getWeight();
int StdWeight();
int getWeightStatus();
};
void standardWeight::setHeight(const double h)
{
height = h;
}
void standardWeight::setWeight(const double w)
{
weight = w;
}
double standardWeight::getHeight()
{
return height;
}
double standardWeight::getWeight()
{
return weight;
}
int standardWeight::StdWeight()
{
if( (height - 100) * 0.9 < weight )
{
// 과체중
WeightStatus = 1;
return 1;
}
else if( (height - 100) * 0.9 > weight )
{
// 저체중
WeightStatus = -1;
return -1;
}
else
{
WeightStatus = 0;
return 0;
}
}
int standardWeight::getWeightStatus()
{
return WeightStatus;
}
int main()
{
standardWeight sw1;
sw1.setHeight(170);
sw1.setWeight(60);
sw1.StdWeight();
cout << sw1.getWeightStatus() << endl;
return 0;
}
'실습과제 모음' 카테고리의 다른 글
CPP 주말 과제 Time 클래스 (0) | 2012.07.27 |
---|---|
CPP ImaginaryNumber (0) | 2012.07.27 |
CPP 함수 실습과제 (0) | 2012.07.25 |
CPP 함수 cvr, cba, cbv (0) | 2012.07.24 |
CPP 실습과제 0724 배열, 함수 (0) | 2012.07.24 |