Shanil P.

asked • 07/28/22

C++ coding for BMI Calculator

can anyone fix this?...im having some error in this c++ code.


#include <iostream>

#include <string>


using namespace std;


class Person{

public:

string name;

int age;

float weight;

float height;

float bmi()

{

bmi = (weight/(height*height))*10000;

return bmi;

}

string status()

{

if(bmi<18.5){

status ="Underweight";

}

else if(bmi>25.99 && bmi<30.01){

status ="Overweight";

}

else if(bmi>30.99 && bmi<40.01){

status ="Obese";

}

else{

status ="Normal Weight";

}

return status;

}

};


int main(){

Person person;

cout << "Name = ";

cin >> person.name;

cout << "Age = " ;

cin >> person.age;

cout << "Weight = ";

cin >> person.weight;

cout << "Height = ";

cin >> person.height;

cout << "Bmi = " << person.bmi();

cout << "Status = " << person.status();

return 0;

}

1 Expert Answer

By:

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.