Advertisement
MonroCoury

bmi_calc

Dec 16th, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.43 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. double easyRound(double dbl, short places)
  5. {
  6.     return roundf(dbl * pow(10, places)) / pow(10, places);
  7. }
  8.  
  9. int main()
  10. {
  11.     double w;
  12.     double h;
  13.     std::cout << "please enter your weight in kg:  ";
  14.     std::cin >> w;
  15.     std::cout << "\nplease enter your height in meters:  ";
  16.     std::cin >> h;
  17.    
  18.     double bmi = w / (h * h);
  19.     std::cout << "BMI is:  " << easyRound(bmi, 3) << "\n";
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement