Search

'계산'에 해당되는 글 1건

  1. 2012.07.26 CPP 표준체중 계산 프로그램

CPP 표준체중 계산 프로그램

실습과제 모음 2012. 7. 26. 13:48 Posted by TanSanC
336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

#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