Question: Calories ASSIGNMENT: Write a program to display the total number of calories in a meal. Ask the user for the number of fat grams, the

Calories

ASSIGNMENT:

Write a program to display the total number of calories in a meal. Ask the user for the number of fat grams, the number of carbohydrate grams, and the number of protein grams in the meal, and display the number of calories from the fat grams, the number of calories from the carbohydrate grams, the number of calories from the protein grams, and the total number of calories in the meal. Create 3 functions to calculate the number of calories from the grams consumed.

The number of calories in 1 gram of fat is 9. The number of calories in 1 gram of carbohydrates is 4. The number of calories in 1 gram of protein is 4.

Use a singular / plural decision to appropriately display an "s" on the output when necessary.

There is no validation.

Example Run #1: (bold type is what is entered by the user)

Enter the number of fat grams in your meal: 1 Enter the number of carbohydrate grams in your meal: 1 Enter the number of protein grams in your meal: 1

The number of calories from the 1 fat gram consumed is 9 calories. The number of calories from the 1 carbohydrate gram consumed is 4 calories. The number of calories from the 1 protein gram consumed is 4 calories. The total number of calories consumed is xx calories.

Example Run #2:

Enter the number of fat grams in your meal: 35 Enter the number of carbohydrate grams in your meal: 60 Enter the number of protein grams in your meal: 40

The number of calories from the 35 fat grams consumed is xxx calories. The number of calories from the 60 carbohydrate grams consumed is xxx calories. The number of calories from the 40 protein grams consumed is xxx calories. The total number of calories consumed is xxx calories.

The example runs show EXACTLY how your program input and output will look.

Write in C. Use printf and scanf statements. Use three function statements. And constants.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!