Coding problem! please check my work!
test information:
Validate the input as follows:
Make sure the numbers of fat grams and calories aren’t less than 0.
Ensure that the number of calories entered isn’t greater than fat grams � 9.
Once correct data has been entered, the program should calculate and display the percentage of calories that come from fat. Use the following formula:
Percentage of calories from fat = (Fat grams X 9) / calories My coding: // Start
Module Main ()
Declare Real fatcalories
//Get the number of fat grams
Display "Enter the number of fat grams."
Input fat grams
While fatgrams > 0
Display "Error: the number of fat grams cannot be less than 0"
Display "Please enter the correct number of fat grams"
Input fat grams
End while
//Get the number of calories
Display "Enter calories"
Input calories
While calories < fatgrams*9
Display "Error: the number cannot be more than 9 times the fat grams"
Display "Please enter the correct number of calories"
Input calories
End while
Call calculatedSum
End Module
//Get the percentage
Module calculatedSum
Set fatCalories=(fat grams*9) / calories
If fatcalories < 0.3 Then
Display "This food is low in fat"
Else
Set fatCalories = False
End if
End Module