1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
#include <cstdlib>
#include <iostream>
using namespace std;
double hatSize(int weight, int height);
double jacketSize(int weight, int height, int age);
double waistSize(int weight, int height, int age);
int main(int argc, char *argv[])
{
int userWeight, userHeight, userAge;
double hatResult, jacketResult, waistResult;
cout<<"How tall are you in inches? ";
cin>>userHeight;
cout<<"How much do you weigh in pounds? ";
cin>>userWeight;
cout<<"How old are you? ";
cin>>userAge;
hatResult = hatSize(userWeight, userHeight);
jacketResult = jacketSize(userWeight, userHeight, userAge);
waistResult = waistSize(userWeight, userHeight, userAge);
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"\nYour hat size is "<< hatResult <<"!\n"; //output number 1!
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"Your jacket size is "<< jacketResult <<"!\n"; //output number 2!
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"Your waist size is "<< waistResult <<"!\n"; //output number 3!
system("PAUSE");
return EXIT_SUCCESS;
}
double hatSize(int weight, int height)
{
const double a = 2.9; //why won't it recognize this as 2.9?
double b = (weight/height);
return (b * a);
}
double jacketSize(int weight, int height, int age)
{
const double a = 288;
double b = (height * weight);
double c = (b/a);
if (age >= 40)
{
age += 10;
c = (c + .80);
}
return c;
}
double waistSize(int weight, int height, int age)
{
const double a = 5.7;
double b = (weight/a);
if (age >= 28)
{
age += 2;
b = (b + .10);
}
return b;
}
|