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 Flowchart please
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
Flowchart please
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 5 images