Question: Please write a c++ code for my pseudo code. I am take a class that is teaching me flow charts and pseudocode and I would

Please write a c++ code for my pseudo code. I am take a class that is teaching me flow charts and pseudocode and I would like to see the actual code so that I can start preparing myself for next semesters classes. Here is the pseudo code:

// main module

Module main()

// Local variables

Declare Integer gramsFat, calories

// Get fat grams

Set gramsFat = getFat()

// Get calories

Set calories = getCalories(gramsFat)

// Show percent calories from fat

Call showPercent(gramsFat, calories)

End Module

// The getFat function gets grams of fat

Function Integer getFat ()

Declare Integer inputAmount

// enter count

Display Enter grams of fat:

Input inputAmount

// validate rate

While inputAmount < 0

Display Quantity must not be less than 0!

Display Enter a valid quantity.

Input inputAmount

End While

return inputAmount

End Function

// The getCalories function gets number of calories

Function Integer getCalories(gramsFat)

Declare Integer inputAmount, maxCalories

Set maxCalories = gramsFat * 9

// enter count

Display Enter number of calories:

Input inputAmount

// validate rate

While inputAmount < 0 OR inputAmount > maxCalories

Display Quantity must be between 0 and ,maxCalories, !

Display Enter a valid quantity.

Input inputAmount

End While

return inputAmount

End Function

// The showIncome module shows percent calories from calories and grams of fat

Module showPercent(gramsFat, calories)

Declare Real percentCalories

Set percentCalories = (gramsFat * 9) / calories

Display Percentage of calories from fat is , percentCalories

Outpout should look like this:

NOTE: The second bullet of the problem SHOULD read:

According to nutritional formulas, the number of (total) calories MUST exceed fat gramsX 9 (otherwise the meal is ALL fat). Make sure that the number of (total) calories entered IS greater than fat grams X 9.

This program calculates the % of calories from fat in a food, and signals when a food is low fat. When asked,... enter the number of fat grams and calories in the food. Enter the number of fat grams (not less than 0.0 grams) -1 Enter the number of fat grams (not less than 0.0 grams) 4 Enter the number of calories (MUST exceed 36.0 (fat grams X 9.0)) 30 Enter the number of calories (MUST exceed 36.0 (fat grams X 9.0)) 100 The percentage of fat in this food is 36.0%. Press 'c' to continue OR 'q' to QUIT c Enter the number of fat grams (not less than 0.0 grams) 3 Enter the number of calories (MUST exceed 27.0 (fat grams X 9.0)) 100 This food is considered low fat because the percentage of fat: 27.0%, is below 30.0%. Press 'c' to continue OR 'q' to QUIT q Good Bye

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!