Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double calculate_index(double weight, int height)
  6. {
  7.     double heightInMeters = height / 100;
  8.     double index = weight / (heightInMeters*heightInMeters);
  9.    
  10.     return index;
  11. }
  12.  
  13. int main()
  14. {
  15.     double height, weight;
  16.    
  17.     cin>>height>>weight;
  18.    
  19.     double index = calculate_index(weight, height);
  20.    
  21.     if(index < 18.5){
  22.         cout<<"Underweight"<<endl;
  23.     }
  24.     else if(index < 25)
  25.     {
  26.         cout<<"Normal"<<endl;
  27.     }
  28.     else if(index < 30){
  29.         cout<<"Overweight"<<endl;
  30.     }
  31.     else{
  32.         cout<<"Obesity"<<endl;
  33.     }
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement