-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbmi.cpp
55 lines (50 loc) · 919 Bytes
/
bmi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include "bmi.h"
#include <cmath>
#include <cstdlib>
#include <iostream>
using namespace std;
void BMI::setheight(int h){
height = h;
}
void BMI::setmass(int m){
mass = m;
}
void BMI::setbmi(){
height = height/100;
bmi = mass/pow(height,2);
if(height == 0 && mass == 0){
exit(1);
}
}
float BMI::getbmi(){
return bmi;
}
void BMI::setrange(){
if(bmi<15){
range = "Very severly underweight";
}
else if(bmi>=15 && bmi <16){
range = "Severely underweight";
}
else if(bmi>=16 && bmi<18.5){
range = "Underweight";
}
else if(bmi>=18.5 && bmi<25){
range = ("Normal");
}
else if(bmi>=25 && bmi<30){
range = "Overweight";
}
else if(bmi>=30 && bmi<35){
range = "Obese Class I (Moderately obese)";
}
else if(bmi>=35 && bmi<40){
range = "Obese Class II (Severely obese)";
}
else if(bmi>=40){
range = "Obese Class III (Very severely obese)";
}
}
string BMI::getrange(){
return range;
}