Write a program that asks for the user\'s height (float type/in inches), weight
ID: 3630821 • Letter: W
Question
Write a program that asks for the user's height (float type/in inches), weight (float type/ in pounds), and age (an integer type), and then computes and prints the clothing sizes according to the following formulas, i.e., computes and prints the following 3 items.1. Hat size = weight in pounds divided by height in inches and all that multiplied by 2.9.
2. Jacket size (chest in inches) = height times weight divided by 288 and then adjusted by adding one-eighth of an inch for each 10 years over age 30. (Note that the adjustment only takes place after a full 10 years. So, there is no adjustment for ages 30 through 39, but one-eighth of an
inch is added for age 40.)
3. Waist in inches = weight divided by 5.7 and then adjusted by adding one-tenth of an inch for each 2 years over age 28. (Note that the adjustment only takes place after a full 2 years. So, there is no adjustment for age 29, but one-tenth of an inch is added for age 30.)
Explanation / Answer
#include<stdio.h>
int main()
{
float height,weight;
int age;
float hatSize,jacketSize,waist;
printf("Enter your height in inches please:");
scanf("%f",&height);
printf(" Enter your weight in pounds please:");
scanf("%f",&weight);
printf(" Enter your age in years please: ");
scanf("%d",&age);
hatSize=(weight/height)*2.9;
if(age>30) jacketSize=height*weight/288+((age-30)/10)*(1/8); /*if age >30 substract 30 from it, divide by 10(intger division) this gives adjustment. e.x if age is 48, (48-30)=18,18/10=1,so adjusmnet is 181/8*/
else jacketSize=height*weight/288;
if(age>28) waist=weight/5.7+((age-28)/2)*(1/10); /*adjustment same as above but just replace 30 by 28 and 10 by 2*/
printf(" hat size =%f",hatSize);
printf(" jacketsize =%f inches",jacketSize);
printf(" waist =%f inches",waist);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.