Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions