fork download
  1. /*******************************************************************************
  2.  * Aiden Stannard // CS1A // Chapter 4 Homework: Challange 5# // 9/26/2026
  3.  *
  4.  * Calculate BMI
  5.  *
  6.  * This program recieves a height in inches and the weight in pounds of an
  7.  * individual, calculates the BMI, and outputs if the BMI is overweight,
  8.  * underweight, or within the healthy range.
  9.  *
  10.  * Inputs:
  11.  * Enter your weight in pounds:
  12.  * Now enter your height in inches:
  13.  *
  14.  * Output:
  15.  * Your BMI of ___ is considered (overweight,underweight, or healthy)
  16.  ******************************************************************************/
  17. #include <iostream>
  18. #include <cmath>
  19. using namespace std;
  20.  
  21. int main()
  22. {
  23. float weight;
  24. float height;
  25. float BMI;
  26.  
  27. cout << "Enter your weight in pounds: " << endl;
  28. cin >> weight;
  29. cout << "Now enter your height in inches: " << endl;
  30. cin >> height;
  31.  
  32. BMI = weight * 703.0 / pow(height,2);
  33.  
  34. if (BMI >= 18.5 && BMI <= 25)
  35. cout << "Your BMI of " << BMI << " is within the healthy range" << endl;
  36. else if (BMI < 18.5)
  37. cout << "Your BMI of " << BMI << " is considered underweight" << endl;
  38. else
  39. cout << "Your BMI of " << BMI << " is considered overweight\n";
  40. return 0;
  41. }
Success #stdin #stdout 0.01s 5312KB
stdin
205
72.8


stdout
Enter your weight in pounds: 
Now enter your height in inches: 
Your BMI of 27.1923 is considered overweight