bmiCalculator...check my code

Reply

Join Date: Mar 2006
Posts: 12
Reputation: dors_zone is an unknown quantity at this point 
Solved Threads: 0
dors_zone dors_zone is offline Offline
Newbie Poster

bmiCalculator...check my code

 
0
  #1
Mar 29th, 2006
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;
}
Reply With Quote Quick reply to this message  
Join Date: Mar 2006
Posts: 176
Reputation: dubeyprateek is an unknown quantity at this point 
Solved Threads: 23
dubeyprateek's Avatar
dubeyprateek dubeyprateek is offline Offline
Junior Poster

Re: bmiCalculator...check my code

 
0
  #2
Mar 30th, 2006
hope this can help.

float bmiCalculator(float lbs,float ft) {
return ((lbs * .454) /(ft * ft * .3046 * .3046 )) ;
}
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:




Views: 2232 | Replies: 1
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2010 DaniWeb® LLC