The manager of Willow Springs Health club wants a program that allow her to ente
ID: 671905 • Letter: T
Question
The manager of Willow Springs Health club wants a program that allow her to enter the number of calories and grams of fat contained in a specific food. The program should calculate and display two values: the food's fat calories and its fat percentage. The fat calories are the number of calories attributed to fat and are calculated by multiplying the food's fat grams by the number9; this is because each gram of fat contains 9 calories. The fat percentage is the ratio of food's fat calories to its toatal calories. You calculate the fat percentage by dividing the food's calories by its total calories and the multiplying the resut by 100. The fat percentage should be displayed with zero decimals.
Explanation / Answer
#include <stdio.h>
int main()
{
float fp,calories,gof,fc;
printf("enter the number of calories: ");
scanf("%f",&calories);
printf("enter the grams of fat contained in the food: ");
scanf("%f",&gof);
fc=gof*9;
printf("the food's fat calories are: %.2f",fc);
fp=(fc/calories)*100;
printf(" fat percentage is: %.2f",fp);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.