예제 #1
0
파일: lab2.cpp 프로젝트: cccccroge/lab2
int main() {
	
	int w;
	float h, n;

	BMI bmi;

	ifstream read("file.in", ios::in);
	ofstream write("file.out", ios::out);

	while (read >> h >> w){

	  if (h == 0 && w == 0) break;

	  bmi.setHeight(h);
	  bmi.setWeight(w);
	  n = bmi.calculateBMI();  
	  write << n << " " << bmi.categoryForBMI(n) << endl;
	}

	read.close();
	write.close();
	
	return 0;
}
예제 #2
0
파일: main.cpp 프로젝트: kijy5428/lab2
int main() {

	BMI bmi;
	float height,weight,output;
	string category;

	ifstream inFile("file.in",ios::in);
	if(!inFile)
	{

		cerr << "Failed opening " << endl;
		exit(1);
	}	

	
	ofstream outFile("file.out",ios::out);
	if(!outFile){

		cerr << "Failed opening " << endl;
		exit(1);

	}

	while(inFile>>height>>weight){


		if(height !=0){
			
			bmi.setHeight(height);
			bmi.setWeight(weight);
			
			output = bmi.getBMI();
			category = bmi.getCategory();
			
			outFile<<fixed<<setprecision(2)<<output<<"\t" <<category<< endl;
		}
		else
			break;
	}
	

	return 0;
}