//NAME      : LIM SIN JIE
//IC NUMBER : 000521130688
//NAME     : LUHUNG AKSYARA ADJI
//IC NUMBER : 201908M10180
//SECTION   : 03
//DATE      : 10-11-2019
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double getBMI(double,double);
void dispStatus(double);

int main()
{
	string name;
	int numperson=0;
	double weight,height,BMI,totalweight=0,totalheight=0,overallweight,overallheight,overallBMI;
	cout << "Enter name or press <ENTER> key to end => ";
	getline(cin,name);
	while(name !="")
	{
		cout << "Enter weight(kg) and height(m) => ";
		cin >> weight >> height;
		numperson++;
		totalweight+=weight;
		totalheight+=height;
		BMI = getBMI(weight,height);
		cout<<"\nName  : "<<name;
		cout<<fixed<<showpoint<<setprecision(2);
		cout<<"\nWeight: "<<weight<<" kilograms";
		cout<<"\nHeight: "<<height<<" meters";
		cout<<"\nBMI   : "<<BMI<<endl;
		dispStatus(BMI);
		
		cout << "\n\nEnter name or press <ENTER> key to end => ";
		cin.ignore();
		getline(cin,name);	
	}	
	overallweight = totalweight/numperson;
	overallheight = totalheight/numperson;
	overallBMI = getBMI(overallweight,overallheight);
	cout<<"\n\nOverall BMI : "<<overallBMI;
	cout<<"\nOverall ";
	dispStatus(overallBMI);
}
double getBMI(double W, double H)
{
	return (W/pow(H,2));
}
void dispStatus(double BMI)
{
	string status;
	if(BMI<18.5)
	    status = "Underweight";
	else if(BMI<=25)
	    status = "Normal";
	else if(BMI<=30)
	    status = "Overweight";
	else
	    status = "Obese";
	cout<<"Status: "<<status;
}






