int main() { BMI Bmi; int i; float h,w,b; Bmi.h=170; Bmi.w=65; ifstream filein("file.in"); ofstream fileout("file.out",ios::out); while(filein>>h>>w){ if(h==0&&w==0) break; fileout<<Bmi.bmi(h,w)<<" "<<Bmi.category(h,w)<<endl; } filein.close(); fileout.close(); return 0; }
int main(){ BMI b; float height,weight; ifstream inFile("file.in",ios::in); if(!inFile){ cerr<<"Error"<<endl; exit(1); } ofstream outFile("file.out",ios::out); if(!outFile){ cerr<<"Error"<<endl; exit(1); } while(inFile>>height>>weight){ if(height == 0 && weight == 0) return 0; outFile<<b.bmi(height,weight); outFile<<"\t"<<b.set()<<endl; } return 0; }