#include <iostream>
using namespace std;
// There will be three functions performing the
// Hat size, Jacket size, and Waist size calculations
// All of which are designated before and after main.
// Algorithm:
// Get the users height, weight, age.
// Caclculate the HatSize, JacketSize, and WaistSize
// given the coorelating formulas provided by Hare
// for each seperate formula making a function for each.
// hat func
int JacketSize(int Ht, int Wt, int Age);
// PRE: given inputs
// POST: do the formula
// PRE: given inputs
// POST: do the formula
int WaistSize(double Ht, double Wt, double Age);
double HatSize(double Ht, double Wt);
int main()
{
int Ht, Wt, Age, CalcdHatSize, CalcdJacketSize, CalcdWaistSize ;
char answer;
do {
cout << "What is your weight in pounds?" ;
cin >> Wt;
cout << "What is your height in inches?" ;
cin >> Ht;
cout << "What is your age in years?" ;
cin >> Age;
cout << "Hat size is " << HatSize(Ht, Wt) << endl;
cout << "Jacket size is " << JacketSize(Ht, Wt) << endl;
cout << "Waist size is " << WaistSize(Ht, Wt) << endl;
cout << "Do you wish to enter more data? ";
cin >> answer;
while(answer != 'N' && answer != 'n');
return 0;
}
double HatSize(double Ht, double Wt)
{
double CalcdHS;
CalcdHS = ((Wt / Ht) * 2.9); //equation for a person hat size
return CalcdHS; // returning the value produced from the given inputs form main
}
int JacketSize(int Ht, int Wt, int Age)
{
double CalcdJS;
CalcdJS = Ht * Wt / 288.0; // equation of persons jacket size
if (Age > 30)
CalcdWS += ((Age - 30) / 10) * 1.0/8.0 //iff over 30 then
adjust made
return (int) (CalcdJS + 0.5);
}
// jacket conversion if over 30 years old return adjusted value
int WaistSize(int Ht, int Wt, int Age)
{
double CalcdWS;
CalcdWS = Wt / 5.7; // formula for waist size
if (Age > 28)
CalcdWS += ((Age - 28) / 2) * 1.0/10.0; // if over 28
adjuster per 2 years by 1/10
return (int) (CalcdWS + 0.5);
}
// waist conversion is over 28 years old return the adjusted value