실습과제 모음

CPP 실습문제 0714

TanSanC 2012. 7. 14. 11:32

#include <iostream>
using namespace std;

class Weight
{
public :
 void setHeight(const double h);
 void setWeight(const double h);
 double getHeight();
 double getWeight();
 int    getWeightStatus();

private :
 int    StdWeight();
 double height, weight;
 int    WeightStatus;
};


void Weight::setHeight(const double h)
{
}

void Weight::setWeight(const double w)
{
}

double Weight::getHeight()
{
}

double Weight::getWeight()
{
}

int Weight::StdWeight()
{
 double sw=(height-110)*0.9;

 if (sw+0.5 < weight)
  WeightStatus=1;
 else if (sw-0.5 > weight)
  WeightStatus=-1;
 else
  WeightStatus=0;

 return 1;
}

int Weight::getWeightStatus()
{
}

int main()
{
 Weight w1; 
 w1.setHeight(175);
 w1.setWeight(87.5);
 cout << w1.getHeight() << "키에 몸무게 ";
 cout << w1.getWeight() << "는 ";
 switch (w1.getWeightStatus())
 {
 case 1:
  cout << "과체중";
  break;
 case 0 :
  cout << "정상";
  break;
 case -1:
  cout << "저체중";
  break;
 default:
  ;
 }
 cout << " 입니다." << endl;

 return 0;
}

 

include.dotx