Reference no: EM13166665
Starting out with Programming logic and design 3rd Author Tony Gaddis - Pg 279, PE 3 Fat Grams Calculator
Design a program that asks for the number of fat grams and calories in a food item and Validate the input
Please help me with the structure and the order of the statements.
This is supose to be written in pseudocode
Declare Integer calories, fatGrams, maxGrams
Declare Real pFatcal
Display "Please Enter the number calories in the food item."
Input calories
// Confirm calories not less than zero.
While calories < 0
Display "ERROR: The number of calories can't be less than zero."
Display "Please enter a valid number of calories."
Input calories
End While
Display "Please Enter the number fatGrams in the food item."
Input fatGrams
// Confirm fat Grams not less than zero.
While fatGrams < 0
Display "ERROR: The number of fat grams can't be less than zero."
Display "Please enter a valid number of fat grams."
Input fatGrams
End While
// Calculate percentage of calories from fat
// according to nutritional formulas, the number of calories can't exceed fat grams times 9
// confirm calories entered are not greater than fatGrams times 9.
maxGrams = fatGrams * 9
While calories <= maxGrams
pFatcal = (fatGrams * 9)/ calories
Display "The percentage of calories from fat is: " pFatcal
// Check to see if the item is low fat.
If pFalcal < 0.3
Display "Great Work! This food item is Low Fat. "
End If