/* KHOR YONG XIN (991113-07-6264) SECTION 02
   TEE HUI YOU (001005-10-1332) SECTION 02
   9/11/2019 
   QUESTION 2 */

#include <iostream>
#include <cmath>
#include <iomanip>
#define MAX 100
using namespace std;

float getBMI (float x, float y)
{
	float BMI;
	
	return BMI = x / pow(y,2);
}

void dispStatus (float BMI)
{
	if (BMI < 18.5)
		cout << "Underweight" << endl;
	else if (BMI <= 25)
		cout << "Normal" << endl;
	else if (BMI <= 30)
		cout << "Overweight" << endl;
	else 
		cout << "Obese" << endl;
}

int main ()
{
	int numPerson;
	char str[MAX];
	float weight, height, BMI, overallBMI;
	float overallWeight = 0, overallHeight = 0;
	
	cout << "Please enter the number of person you want to enter: ";
	cin >> numPerson;
	cout << endl;
	
	for (int i = 1; i <= numPerson; i++)
	{
		cout << "Enter name => ";
		cin.ignore();
		cin.getline(str,MAX);
		
		cout << "Enter weight (kg) and height (m) => ";
		cin >> weight >> height;
		cout << endl;
		
		overallWeight = (overallWeight + weight)/i;
		overallHeight = (overallHeight + height)/i;
		
		BMI = getBMI (weight, height);
		
		cout << "Name  : " << str << endl;
		cout << fixed << setprecision(2);
		cout << "Weight: " << weight << " kilograms" << endl;
		cout << "Height: " << height << " meters" << endl;
		cout << "BMI   : " << BMI << endl;
		cout << "Status: ";
				dispStatus (BMI);
		cout << endl;
	
		while ((str,MAX) == '0')
			break;
	}
	
	BMI = overallWeight / pow (overallHeight,2);
	
	cout << "Overall BMI : " << BMI << endl;
	cout << "Overall Status : ";
			dispStatus (BMI);
	
	return 0;
}
