//MOHAMAD AMIN HAZEEQ BIN HISHAM
//000804-01-1523
//MUHAMMAD ARIFF FANSURI ABDULRAZAK BIN ROHAIZAD
//000705-10-0467
//SECTION 2 
//12 NOVEMBER 2019

#include <iostream>
#include <iomanip>
using namespace std;

double getBMI(double weight,double height)
{
	double BMI=weight/(height*height);
	return BMI;
}
void dispStatus(double BMI)
{
	if(BMI<18.50){
		cout<<"Underweight";
	}else if(BMI<25){
		cout<<"Normal";
	}else if(BMI<30){
		cout<<"Overweight";
	}else if(BMI>=30){
		cout<<"Obese";
	}
}
int main()
{
	const int MAX=999;
	char name[MAX];
	int x=0;
	double weight;
	double height;
	int count=0;
	double OverallWeight=0;
	double OverallHeight=0;
	cout<<"Press Enter to START."<<endl;
	
	do
	{
    cin.clear();
	cin.ignore();
	cout<<"Enter name or press <ENTER> key to end => ";
	cin.getline(name,MAX);
	if(name[0]=='\0')
	break;
	cout<<"Enter weight (kg) and height (m) => ";
	cin>>weight>>height;
	cout << fixed << setprecision(2) << endl;
	cout<<endl;
	static_cast<double>(weight);
	static_cast<double>(height);
	double BMI=getBMI( weight, height);
	
	cout<<"Name : "<<name<<endl;
	cout<<"Weight : "<<weight<<" kilograms"<<endl;
	cout<<"Height : "<<height<<" meters"<<endl;
	cout<<"BMI : "<<BMI<<endl;
	cout<<"Status : ";
	dispStatus(BMI);
	cout<<endl<<endl;
	
	OverallWeight=OverallWeight+weight;
	OverallHeight=OverallHeight+height;
	count++;
	
	
	}while(x==0);
	double avgw=OverallWeight/count;
	double avgh=OverallHeight/count;
	double OverallBMI=getBMI(avgw,avgh);
	
	cout<<"\n\nOverall BMI : "<<OverallBMI<<endl;
	cout<<"Overall Status : ";
	dispStatus(OverallBMI);
	cout<<endl;
	
return 0;	
}
