fork download
  1. //Conrad Taylor CSC5 Chapter 4, P. 220, #5
  2. //
  3. /*******************************************************************************
  4.  * Number Size Comparitor
  5.  * _____________________________________________________________________________
  6.  * This program takes the users height and weight as input, calculates their
  7.  * body mass index, then tells the user whether they are underweight, healthy,
  8.  * or overweight based on a predetermined range of bodyfat percentages.
  9.  * _____________________________________________________________________________
  10.  * INPUT
  11.  * number1
  12.  * number2
  13.  ******************************************************************************/
  14.  
  15. #include <iostream>
  16. #include <cmath> // Included for using pow() function.
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. // Variables
  22. float BMI, weight, height;
  23.  
  24. cout << "Enter your weight: " << endl;
  25. cin >> weight;
  26. cout << "Enter your height in inches: " << endl;
  27. cin >> height;
  28.  
  29. BMI = (703/ pow(height, 2)) * weight;
  30.  
  31. cout << "BMI = " << BMI << endl;
  32.  
  33. if (BMI >= 0 && BMI <= 18.5)
  34. cout << "Under Weight." << endl;
  35. else if (BMI > 18.5 && BMI <=25)
  36. cout << "Optimal Weight." << endl;
  37. else if (BMI > 25)
  38. cout << "Over Weight." << endl;
  39.  
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
Enter your weight: 
Enter your height in inches: 
BMI = inf
Over Weight.