using c++ Write a program that reads from a file the customer number, height (in
ID: 3577102 • Letter: U
Question
using c++
Write a program that reads from a file the customer number, height (in inches), weight and age of 10 individuals. This program then computes clothing sizes for each individual based on the following formulas.
Hat size = weight in pounds divided by height in inches and all that multiplied by 2.9
Jacket size = height times weight divided by 288 and then adjusted by adding 1/8 of an inch for each 10 years over age 30. (NOTE: the adjustment only takes place after a full 10 years. So, there is no adjustment for ages 30 through 39, but 1/8th of an inch is added for age 40, and so on). Do not use nested if statements for this.
Pant size = weight divided by 5.7 and then adjusted by adding 1/10th of an inch for each 2 years over age 28. (NOTE: the adjustment only takes place after a full 2 years. So, there is no adjustment for age 29, but 1/10th of an inch is added for age 30 and so on). Do not use nested if statements for this.
Use function for each calculation, as well as a function to read in the data from a file and a function to print the results to an output file.
Input File
120 77 210 40
121 70 185 45
122 68 170 51
123 72 200 31
124 70 210 63
125 72 189 29
126 70 220 42
127 75 250 25
128 66 150 39
129 72 150 22
Output File should have the following:
Page heading
Column headings
Columns for id, height, weight, age, hat size, jacket size, and pant size.
"i need alot of help on the functions for each"
Explanation / Answer
Executable Code:
#include<iostream>
using namespace std;
void hatsize(double, double);
void jacsize(double,double, int);
void waist(double,int);
int main()
{
double height, weight;
int age;
char c='y';
while(c=='y'||c=='Y')
{
cout<<"Enter you Height: ";
cin>>height;
cout<<" Enter Weight: ";
cin>>weight;
cout<<" Enter age: ";
cin>>age;
hatsize(height,weight);
jacsize(height,weight,age);
waist(weight,age);
cout<<" Are you like to Repeat (y for yes):";
cin>>c;
}
system("pause");
return 0;
}
void hatsize(double h, double w)
{
cout<<"Hat Size: "<<((w/h)*2.9);
}
void jacsize(double h, double w, int a)
{
double ag=0.0;
double size=((h*w)/288);
while(a>30)
{
if(a%10==0)
ag+=1/8;
a/=10;
size+=ag;
cout<<" Jacket Size: "<<size;
}
}
void waist(double w, int a)
{
double wst=w/5.7;
double inc=0.0;
while(a>28)
{
inc+=0.1;
a-=2;
}
wst+=inc;
cout<<" Waiste Size: "<<wst;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.