PLZ HELP EASY PSEUDOCODE

This is my second assignment and it is way more confusing i have a few different ideas on possible pseudocode. ANY FEEDBACK HELPS!!!! THANKS

QUESTION : Calculate number of calories from FAT and CARBs for your food diet. Enter numbers of fat grams and Carbohydrate grams from the keyboard (don't forget user prompt)

CaloriesFromFat=FatGrams * 9;
CaloriesFromCarbs=CarbsGrams * 4;

a) design a traditional program as one piece, as we did in class before.

b) design a module (function) that takes two parameters, 1) "fat" or "carb" as text, 2) grams as a number then calculates the number of calories and displays it together with the food type.




1
2
3
4
5
6
7
8
9
10
 Float caloriesfromfat,caloriesfromcarb, fatgrams, carbgrams, totalcalories
print ”enter fat grams”
read fatgrams
print “enter carb grams”
read carbgrams
caloriesfromFat=FatGrams * 9;
caloriesfromCarbs=CarbsGrams * 4;
totalcalories = sum caloriesfromcarbs, caloriesfromFat
Print “your total calories:” totalcalories
Anyone have any idea if this is atleast along the lines of being correct??
Well, that looks good with one possible amendment if you interpret "b" as I do from here...

It seems that the program should print "fat calories: " caloriesfromFat, and the same for carbs, before the total calories.

Whether that's for both forms a and b I'm not sure.

That is to say I think 6 and 7 should also print in both forms.

Is this going into code now?
Thanks for the reply really helped alot bro, and no it is not going into code the assignment is to complete it in pseudocode.

So this is the correction you suggested right?

1
2
3
4
5
6
7
8
9
10
11
Float caloriesfromfat,caloriesfromcarb, fatgrams, carbgrams, totalcalories
print ”enter fat grams”
read fatgrams
print “enter carb grams”
read carbgrams
caloriesfromcat=FatGrams * 9;
print "fat calories: " caloriesfromfat
caloriesfromcarbs=CarbsGrams * 4;
Print “carbs calories: “ caloriesfromcarbs
totalcalories = sum caloriesfromcarbs, caloriesfromFat
Print “your total calories:” totalcalories
That looks right to me, but for a). Now, you need one for b)
Topic archived. No new replies allowed.