C++ const double type initialize
#include <iostream> #include <iomanip> int main(){/* ww w. j a v a 2s . c o m*/ const double lbs_per_kg {2.2}; const double inches_per_foot {12.0}; const double meters_per_foot {0.3048}; double w_lbs {}; unsigned int h_feet {}; unsigned int h_inches {}; std::cout << "Enter your weight in pounds: "; std::cin >> w_lbs; std::cout << "Enter you height in feet and inches: "; std::cin >> h_feet >> h_inches; double w_kg {w_lbs/lbs_per_kg}; double h_meters {}; h_meters = meters_per_foot*(static_cast<double>(h_feet) + h_inches/inches_per_foot); double bmi {w_kg / (h_meters*h_meters)}; std::cout << "Your BMI is " << std::fixed << std::setprecision(1) << bmi << std::endl; }