#include <iostream>
#include <cmath>
#include <iomanip>
#include <cctype>
using namespace std;

double getBMI (double, double);
void dispStatus(double);

int main()
{
	int number=0;
	double weight,totalWeight=0, OverallWeight, height,totalHeight=0, OverallHeight, BMI, OverallBMI;
	char name[30], Name[30];
	
	cout << fixed << setprecision(2);

    do
    {
    	if(number != 0)
    	{	
    		cin.ignore();
      	    cin.clear();		
		}
		      	
		cout << "Enter name or <Enter> to exit => ";
	    cin.getline(name, 30);
	    if(name[0]=='\0')
	    {
	    	break;
		}
	    
		cout << "Enter weight (kg) and height (m) => ";
	    cin >> weight >> height;
	    
	    totalWeight += weight;
	    totalHeight += height;
	    number++;
	    BMI=getBMI (weight, height);
	    
	    cout << endl;
	    cout << "Name   : " << name << endl;
	    cout << "Weight : " << weight <<" kilograms" << endl;
	    cout << "Height : " << height <<" meters" << endl;
	    cout << "BMI    : " << BMI << endl;
	    cout << "Status : ";
		dispStatus(BMI);	
		    	
	}while (name[0] !='\0');
		
    OverallWeight=totalWeight/number;
    OverallHeight=totalHeight/number;
    
    if((name[0] =='\0')&&(number ==0))
	{
		cout << "\n\nOverall BMI : No available data" << endl;
	    cout << "Overall Status : No available data ";
	}
	else
	{
		OverallBMI=getBMI (OverallWeight, OverallHeight);
     	cout << "\n\nOverall BMI : " << OverallBMI << endl;
    	cout << "Overall Status : ";
	    dispStatus(OverallBMI);
	}


	return 0;
}

double getBMI (double w, double h)
{
	return (w/(pow(h,2)));
}

void dispStatus(double B)
{
	if ((B>0)&&(B<18.5))
	cout << "Underweight"<<endl;
	else if (B <=25)
	cout << "Normal" << endl;
	else if (B <=30)
	cout << "Overweight"<<endl;
	else if (B>30)
	cout << "Obese"<<endl;
	else
	cout << "You have input invalid value! Run the system again" << endl;
}
