| | |
bmiCalculator...check my code
![]() |
•
•
Join Date: Mar 2006
Posts: 12
Reputation:
Solved Threads: 0
i need to write a function called bmiCalculator, which calculate based on:
a) the function is to be passed the weight n height as parameters. the weight and height in pounds and feet, respectively.
b) the function should convert pounds to kilograms (0.454kilograms per pound) and feet to meters (0.3046 meters per foot).
c) function should calculate and return bmi value using algebric formula
bmi= weight in kilograms / (height in meters)2
the function prototype is : float bmiCalculator(float lbs,float ft);
----------------------------------------------------
Here are what i've done..plz check :
// Test 1/MAR 2006
// A function bmiCalculator is to calculate the body mass index (bmi)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int pounds;
int feet;
float lbs;
float ft;
cout << " " << endl;
cout << "*** Program to calculate body mass index ***" << endl;
cout << "--------------------------------------------" << endl;
cout << " " << endl;
cout << "Enter your weight in pounds"<< endl;
cin >> pounds;
cout << "Enter your height in feet"<< endl;
cin >> feet;
lbs = (pounds * 0.454);
cout << "Your weight in kilograms is "<< lbs << endl;
ft = (feet * 0.3046);
cout <<"Your height in meter is "<< ft << endl;
float bmiCalculator;
bmiCalculator = (lbs/(ft*ft));
cout << "Your body mass index (bmi) is "<< bmiCalculator << endl;
return 0;
}
a) the function is to be passed the weight n height as parameters. the weight and height in pounds and feet, respectively.
b) the function should convert pounds to kilograms (0.454kilograms per pound) and feet to meters (0.3046 meters per foot).
c) function should calculate and return bmi value using algebric formula
bmi= weight in kilograms / (height in meters)2
the function prototype is : float bmiCalculator(float lbs,float ft);
----------------------------------------------------
Here are what i've done..plz check :
// Test 1/MAR 2006
// A function bmiCalculator is to calculate the body mass index (bmi)
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int pounds;
int feet;
float lbs;
float ft;
cout << " " << endl;
cout << "*** Program to calculate body mass index ***" << endl;
cout << "--------------------------------------------" << endl;
cout << " " << endl;
cout << "Enter your weight in pounds"<< endl;
cin >> pounds;
cout << "Enter your height in feet"<< endl;
cin >> feet;
lbs = (pounds * 0.454);
cout << "Your weight in kilograms is "<< lbs << endl;
ft = (feet * 0.3046);
cout <<"Your height in meter is "<< ft << endl;
float bmiCalculator;
bmiCalculator = (lbs/(ft*ft));
cout << "Your body mass index (bmi) is "<< bmiCalculator << endl;
return 0;
}
![]() |
Similar Threads
- could you check my code ? (C)
- Code Check, Please (ASP)
- check this code pleeeeeeeeeease (C++)
- Again please someone check my code (C++)
- Check the code!! (C++)
- DrawHouse code help... (Java)
- DrawHouse Code Problem (Java)
Other Threads in the C++ Forum
- Previous Thread: PLEASE!! Assignment Hollow rectangle with (*)
- Next Thread: help me in statement
Views: 2232 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for C++
algorithm array arrays assignment beginner binary browser c++ c/c++ calculator char class classes client code compile compiler constructor conversion convert count delete dll dynamic encryption error exception file files fstream function functions game givemetehcodez graph gui helpwithhomework homework iamthwee ifstream input int integer lazy link linker list loop looping loops math matrix member memory newbie number object objects opengl output parameter path pointer pointers problem program programming project python random read reading recursion recursive reference sockets sort spoonfeeding string strings struct student studio system template templates text time tree undefined url variable vc++ vector video visual win32 window windows winsock





