clothing size project

This program asks for a users height, weight, and age, and based off of that, it creates a clothing size.

for the jacket size, the height times the weight divided by 288 is supposed to find the right jacket size, but there's a twist. for every 10 years over 30, 1/8th of an inch is added to the height (for fitting reasons). however, I don't get the complete decimal. I've tried set precision and float numbers, but I don't think that worked.

I want to understand how to make the recommended jacket size variable more accurate, rather than just showing 2 numbers after the decimal.


#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <math.h>

using namespace std;

float hatsize(float weight, float height);
float jacketsize(float weight, float height);
float waistsize(float weight);

int main()
{
std::cout << "Enter in your height, weight, and age.";
std::cout << " Must use inches, lbs, and years.\n\n";
float z = 0;
while(z < 999.0)
{
float height;
std::cout << "Height: ";
std::cin >> height;

float weight;
std::cout << "Weight: ";
std::cin >> weight;

float age;
std::cout << "Age: ";
std::cin >> age;

if( height > 0 && weight > 0 && age > 0)
{
std::cout << "Your recommended hat size is " << setprecision(30) << hatsize(weight, height) << '\n'
<< "Your recommended jacket size is " << jacketsize(weight, height) << '\n'
<< "Your recommended waist size is " << waistsize(weight) << '\n'
<< "-------------------------------------------------------------------" << '\n';
}
}
}
float hatsize(float weight, float height)
{
return (weight/height * 2.900);
}
float jacketsize(float weight, float height)
{

float age;
if (age < 30)
{
return (height*weight / 288);
}
if (age >= 30 && age < 40)
{
std::cout << "works";
return ((((height+(0.125)))*weight) / 288);
}
if (age >= 40 && age < 50)
{
return ((((height+(0.25)))*weight) / 288);
}
if (age >= 50 && age < 60)
{
return ((((height+(0.375)))*weight) / 288);
}
if (age >= 60 && age < 70)
{
return ((((height+(0.50)))*weight) / 288);
}
if (age >= 70 && age < 80)
{
return ((((height+(0.625)))*weight) / 288);
}
if (age >= 80 && age < 90)
{
return ((((height+(0.75)))*weight) / 288);
}
if (age >= 90 && age < 100)
{
return ((((height+(0.875)))*weight) / 288);
}
if (age >= 100 && age < 110)
{
return ((((height+(1.00)))*weight) / 288);
}
}
float waistsize(float weight)
{
float age;
return (weight / 5.700);
}
> however, I don't get the complete decimal
don't understand your issue
provide an example input with the expected output and the erroneous one produced by your program.

> "Your recommended jacket size is " << jacketsize(weight, height) << '\n'
you aren't using the `age'
Topic archived. No new replies allowed.