Chap 7 Problem 3 Fat calories and low fat ==Input== Real fatGrams Real calories ==Process== percentageFat = (fatGrams * 9) / Calories ==Output== if percentage < 0.3 then display "The food is low in fat" else Display "The food is not low in fat" end If ==Validate Input== fatGrams > 0.0 calories > 0.0 not (calories > (fatGrams * 9)) ==Pseudo Code for validate== Module main Declare Real fatGrams, Calories = 0 Declare Real fatCalc = 0 Display "What is the number of grams of fat? " Input fatGrams if fatGrams < 0 Then Display "The number of grams from fat is less than zero" End If Display "What is the number of calories? " Input calories if calories < 0 Then Display "The number of grams from fat is less than zero" End If set fatCalc = fatGrams * 9; // Debug // Display "fat calc is ", fatCalc if not (calories > fatCalc) Then Display "The number of calories should be greater than the grams of fat times 9" End If End Module ==Pseudo Code for simple program without validation== Module main Declare Real fatGrams, Calories = 0 Declare fatCalc = 0 Display "What is the number of grams of fat? " Input fatGrams Display "What is the number of calories? " Input calories set percentageFat = (fatGrams * 9) / Calories // Output if percentageFat < 0.3 then Display "The food is low in fat" else Display "The food is not low in fat!" end if end module ==Pseudo Code for the whole she-bang!== Module main Declare Real fatGrams, calories Declare Real fatCalc Declare Real percentageFat Declare boolean test1, test2, test3, inputOk // prime our while loop set inputOk = false // Input // validation loop while inputOk == false // Initialize our three test variables to false set test1 = false set test2 = false set test3 = false Display "What is the number of grams of fat? " Input fatGrams if fatGrams < 0 Then Display "The number of grams from fat is less than zero" set test1 = false else set test1 = true end if Display "What is the number of calories? " Input calories if calories < 0 Then Display "The number of grams from fat is less than zero" set test2 = false else set test2 = true end if // the fat calc validation set fatCalc = fatGrams * 9 // debugging print statement // Display "fat calc is ', fatcalc // Validate if not (calories > fatCalc) Then Display "The number of calories should be greater than the grams of fat times 9" test3 = false else test3 = true end if if (test1 and test2 and test3) then set inputOk = true else set inputOk = false end if end While // while loop and input validation // Process Here set percentageFat = (fatGrams * 9 ) / calories // Output if percentageFat < 0.3 then Display "The food is low in fat') else Display "The food is not low in fat!" end if end module // main