# Is My Pseudocode Correct? - Programming

I am supposed to make a pseudocode for a fat gram calculator. These are the instructions:

Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows:

- Make sure the number of fat grams and calories are not less than 0
- According to nutritional formulas, the number of calories cannot exceed fat grams x 9. Make sure that the number of calories entered is not greater than fat grams x 9.

Once the correct data has been entered the program should calculate and display the percentage of calories that come from fat. Use the following formula:
% of calories from fat = (fat grams x 9) / calories

Some nutritionists classify a food as "low fat" if less than 30& of its calories come from fat. If the results of this formula are less than 0.3, the program should display a message indicating the food is low in fat.

Here is my code:

Declare Real fatGrams, percentCal, calories

Module main()
Display “Enter the number of fat grams.”
Input fatGrams

Display “Enter the number of calories.”
Input calories

Call checkInput()

Set percentCal = calc(fatGrams, calories)

If percentCal < 0.3 then Display “The percentage of calories from fat is”, percentCal, “. This food is low in fat.”
Else
Display “The percentage of calories from fat is”, percentCal
End if
End Module

Module checkInput()
While fatGrams and calories <= 0
Display “You must enter a value greater than 0 for the number of fat grams and calories.”
End while
While calories > fatGrams * 9
Display “The number of calories cannot exceed fat grams times 9.”
End while
End Module

Function calc(Real num1, Real num2)
Declare Real result
Set percentCal = (num1 * 9) / num2
Return result
End Function

1. 👍
2. 👎
3. 👁

## Similar Questions

1. ### Health

4. Which of the following is considered the least harmful to the body? A. Saturated Fat B. Cholesterol C. Unsaturated Fat D. Trans Fat My Answer is B

2. ### chemistry

calculate the number of gram of Al2S3 which can be prepared by the reaction of 20 gram of Al and 30 gram of sulpher . how much the non limiting reactant is in excess?

3. ### chemistry

Calculate the hydronium ion consentration and the hydroxide concentration in blood in which the PH is 7.3. Hydronium = [H3O+] = 10-pH or [H3O+] = antilog (- pH) and I got 1.00 x 10^7.3 for both concentrations is this correct?

4. ### Fat gram calculator

Design a program that asks the user for the number of fat grams and calories in a food item. Validate the input as follows. Make sure the number of fat grams and calories are not less than 0. According to nutritional formulas, the

1. ### math

protein = 4 calories per gram carbohydrate = 4 calories per gram fat = 9 calories per gram A serving of chicken has 27 grams of protein and 3 grams of fat. How many calories are in a serving of chicken?

2. ### Math

Use a calculator to evaluate the trigonometric function. Round to four decimal places. Make sure that your calculator is in the correct angle mode. 1) csc 2pi/5 1.3213? 2) sec 0.7 1.3075?

3. ### Programming

Submit pseudocode and a flowchart for the following programming exercise: Fat Gram Calculator Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: - Make sure the

4. ### Algebra 1

a reduced fat cookie contains 3g of fat per serving. In order for food to be termed reduced fat it must have at least 20% less fat than the regular item. What can you conclude about how much fat is in a serving of the regular

1. ### Science

One hour of bicycle riding can require 500-900 kcal of energy, depending on the speed, the terrain, and the weight of the racer. An individual wants to lose weight by riding at a modest effort, consuming 505 kcal of energy per

2. ### Computer programming

Submit pseudocode for the following programming exercise: Fat Gram Calculator Design a program that asks for the number of fat grams and calories in a food item. Validate the input as follows: - Make sure the number of fat grams

3. ### math

a 14- gram serving of mayonnaise contains 11 grams of fat. what percen tof the mayonnaise, to the nearest tenth of a percent, is fat?

4. ### statistics

sing the proper average, find the average number of grams of fat per ounce of meat or fish that a person would consume over a 5-day period if he ate these: 3 oz fried shrimp 3.33 g/oz of fat 3 oz veal cutlet 3.00 g/oz of fat 2 oz