Ejemplo n.º 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;
}
Ejemplo n.º 2
0
int main(){
	
	ifstream inFile("file.in",ios::in);
	ofstream outFile("file.out",ios::out);

	BMI bmi;
	float result;
	int h,m;
	while(1){
		inFile >> h >> m;
		bmi.setH(h);
		bmi.setM(m);
		if (bmi.getH() == 0 && bmi.getM() == 0){
			break;
		}
		else{
			result = bmi.calculate(bmi.getH(),bmi.getM());
			outFile << fixed 
					<< setprecision(2)
					<< result
					<< " "
					<< bmi.determine(result)
					<< endl;
		}
	}
	return 0;
}
Ejemplo n.º 3
0
Archivo: main.cpp Proyecto: HMKRL/lab2
int main()
{
	BMI body;
	ifstream iF("file.in", ios::in);
	ofstream oF("file.out", ios::out);
	int height, weight;
	oF << fixed << setprecision(2);
	while(1) {
		iF >> height >> weight;
		if(!height && !weight) break;
		body.set_weight(weight);
		body.set_height(height);
		oF << body.get_bmi() << ' ' << body.get_category() << endl;
	}
}
Ejemplo n.º 4
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;
}
Ejemplo n.º 5
0
Archivo: lab2.cpp Proyecto: ZaynF/lab2
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;
}
Ejemplo n.º 6
0
int main(){
	string data;
	ifstream fin("fin.txt",ios::in);
	ofstream fout("fout.txt",ios::out);
	int h,w;
	BMI bmi;
	while(fin>>h>>w){
		
		float bmii = 0;
		bmii=bmi.countbmi(w, bmi.hmeter(h));
		
		data=bmi.category();
		/*cout << "bmi:" << bmii << endl; 
		cout << "data" <<  data << endl;*/	

		fout<<bmii<<"/t"<<data<<endl;
	}
	return 0;
}
Ejemplo n.º 7
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;
}
Ejemplo n.º 8
0
int main(){
        BMI bmi;

        float height,weight,BMI;

        ifstream inFile("file.in",ios::in);
        ofstream outFile("file.out",ios::out);
        if(!inFile){
                cerr << "Failed opening" << endl;
                exit(1);
        }
        if(!outFile){
                cerr << "Failed opening" << endl;
                exit(1);
        }

        while(inFile >> height >> weight){
                outFile << bmi.outBMI(height,weight) ;
                outFile << " " << bmi.outCategory() << endl;
        }
        return 0;
}
Ejemplo n.º 9
0
int main()
{
	int h,m;
	ifstream file_in("file.in",ios::in);
	ofstream file_out("file.out",ios::out);
	if(!file_in || !file_out)
		cout<<"failed to open file."<<endl;
	else
	{
		while((file_in>>h>>m)&&(h!=0 && m!=0))
		{
			BMI value;
			value.setRecord(h,m);
			file_out<<fixed<<setprecision(2)<<value.getBmi()<<"\t";
			file_out<<value.getCotegory()<<endl; 
		
		}	
	}
	file_in.close();
	file_out.close();
	return 0;
}
Ejemplo n.º 10
0
int main()
{
	ifstream inFile("file.in", ios::in);
	ofstream outFile("file.out", ios::out);
	if(!inFile)
	{
		cerr<<"Failed opening"<<endl;
		exit(1);
	}
	double h, m;
	BMI bmi;
	while(inFile>>h>>m)
	{
		if(h==0 && m==0)
			continue;
		bmi.setHeight(h);
		bmi.getHeight();
		bmi.setMass(m);
		bmi.getMass();
		bmi.calBMI(h, m);	
		outFile<<setprecision(4)<<bmi.getBMI()<<"\t"<<bmi.Category()<<endl;
	}
	return 0;
}
Ejemplo n.º 11
-1
int main()
{
  float temp_height = 0, temp_mass = 0;
  BMI bmi;
  
  //判定file.in及file.out能否開啟
  ifstream inFile("file.in",ios::in);
  if(!inFile)
  {
    cout << "file.in open failure." << endl;
    return 0;
  }
  ofstream outFile("file.out",ios::out);
  if (!outFile) 
  {
    cout << "file.out open failure." << endl;
    return 0;
  }

  //從file.in存取資料使用bmi來得到結果並輸出至file.out, 直到讀到的值為0
  while(1)
  {
    inFile >> temp_height >> temp_mass;
    if (temp_height == 0 && temp_mass == 0) break;
    bmi.setHeight(temp_height);
    bmi.setMass(temp_mass);
    outFile << setprecision(4) << setw(5) << setiosflags(ios::left) << bmi.getBMI(); 
    outFile << "  " << bmi.getCategory() << endl;
  }


  return 0;
}