Пример #1
0
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
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;
}