Answer to Question #4952 in Action Script | Flash | Flex | ColdFusion for piyush

Question #4952
Write a short program that asks for your height in centimetres and then converts your height to feet and inches.
1
Expert's answer
2012-06-08T09:48:40-0400
#include <iostream>
int main()
{

const int convFeetoInches = 12;
const double convInchesToMeter = 0.0254;
const double convLBtoKG = 2.2;

using namespace std;
cout.setf(ios_base::fixed, ios_base::floatfield); // fixed-point

int feet = 0;
cout << "Enter your height [feet]: "; cin >> feet; cout << endl;
int inches = 0;
cout << "Enter your height [inches]: "; cin >> inches; cout << endl;
int weight = 0;
cout << "Enter your weight [pounds]: "; cin >> weight; cout << endl;

double heightM = (feet*convFeetoInches + inches)*convInchesToMeter;
double massKG = weight / convLBtoKG;
double BMI = massKG / (heightM*heightM);

cout << "Your BMI is " << BMI;

cin.get();
cin.get();
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
APPROVED BY CLIENTS