C언어 ㄴ
#include<string>
#include <fstream>
using namespace std;
class member
{
private:
string name;
string result;
int kg, cm;
double stkg,over;
public:
string getName(){return name;}
int getKg(){return kg;}
int getCm(){return cm;}
double getStkg(){return stkg;}
double getOver(){return over;}
string getResult(){return result;}
void setName(string n){name=n;}
void setKg(int k){kg=k;}
void setCm(int c){cm=c;}
void setStkg(int c){stkg=(c-100)*0.9;}
void setOver(int k, double st){over=(k/st)*100;}
void setResult(double ov){
if(ov<85) result="저체중";
else if(ov<106) result="정상";
else if(ov<116) result="과체중";
else result="비만";
}
};
int main()
{
member mb[3];
ifstream input;
int i,kg,cm;
string name;
cout<<"이름t체중t키t표준체중t비만도t비만정도n";
input.open("c:\member.txt");
if(input.fail())
return 0;
ofstream output;
output.open("c:\member1.txt");
if (output.fail())
return 1;
i=0;
while(input.eof()==false){
input>>name>>kg>>cm;
mb[i].setName(name);
mb[i].setKg(kg);
mb[i].setCm(cm);
mb[i].setStkg(mb[i].getCm());
mb[i].setOver(kg,mb[i].getStkg());
mb[i].setResult(mb[i].getOver());
cout<<mb[i].getName()<<"t"<<mb[i].getKg()<<"t"<<mb[i].getCm()<<"t"<<mb[i].getStkg()<<"t"<<mb[i].getOver()<<"t"<<mb[i].getResult()<<endl;
output<<mb[i].getName()<<"t"<<mb[i].getKg()<<"t"<<mb[i].getCm()<<"t"<<mb[i].getStkg()<<"t"<<mb[i].getOver()<<"t"<<mb[i].getResult()<<endl;
i++;
}
input.close();
output.close();
system("pause");
}