/*Nurul Alis Alia Binti Mohamad Zamri Section 2
  Mirza Sabrina Binti Mohd Salmi */

#include <iostream>
#include<iomanip>
#include<cmath>
#include<cctype>
using namespace std;
void dispStatus(float );
float getBMI(float , float );

void dispStatus(float BMI)
{
	if (BMI < 18.5)
	cout<< "Status: Underweight";
	else if (BMI <= 25)
	cout<< "Status: Normal";
	else if (BMI <= 30) 
	cout << "Status: Overweight";
	else
	cout << "Status: Obese";
	cout<<"\n\n";
}

float getBMI(float weight, float height)
{
	return weight/pow(height,2);
}

int main()
{
	char name[50];
	float weight,height, BMI,totweight=0,totheight=0,ovweight=0,ovheight=0,ovBMI;
	int i;
	
	cout<<fixed<<setprecision(2);
	
	for(i=1;1;i++)
	{
		cout<<"Enter name or press <ENTER> key to end => ";
		if(i>1)
			cin.ignore();
		cin.getline(name,50);
		if(name[0]!='\0')
		{
			while(1)
			{
				cout<<"Enter weight(kg) and height(m) => ";
				cin>>weight>>height;
				if(weight<0||height<0)
				cout<<"Invalid input. Weight and height cannot be less than zero."<<endl;
				else
				break;
			}
			BMI=getBMI(weight,height);
			cout<<"\nName  : "<<name<<endl
				<<"Weight: "<<weight<<" kilograms"<<endl
				<<"Height: "<<height<<" meters"<<endl
				<<"BMI   : "<<BMI<<endl;
			dispStatus(BMI);
			totweight+=weight;
			totheight+=height;
		}
		else
		{
		--i;
		break;
		}
	}
	
	ovweight=totweight/i;
	ovheight=totheight/i;
	ovBMI=getBMI(ovweight,ovheight);
	cout<<"\n\nOverall BMI: "<<ovBMI<<endl;
	cout<<"Overall ";
	dispStatus(ovBMI);
	
	return 0;
}
