FANDOM


This is how to create a program that will calculate the amount of calories in a food with given amounts of fat, carbohydrates (carbs), and protein (all measured in grams).

Notes Edit

  • For each gram of fat, there are 9 calories.
  • For each gram of carbs, there are 4 calories.
  • For each gram of protein, there are 4 calories.

Program Edit

PROGRAM:CALORIES                    <-- Program title.
:ClrHome                            <-- Clears the home screen.
:Disp "**Calorie-Calc**"            <-- Displays the text "**Calorie-Calc**"
:Input "Fat=",F                     <-- Asks the user to input the amount of fat in grams.
:Input "Carbs=",D                   <-- Asks the user to input the amount of carbs in grams.
:Input "Protein=",P                 <-- Asks the user to input the amount of protein in grams.
:9F+4D+4P→C                        <-- Finds the amount of calories by multiplying the amount of fat by 9, the carbs by 4, and the protein by 4, and then adding.
:Disp "----------------"            <-- Displays a line to separate the amounts of fat, carbs, and protein from the amount of calories.
:Disp "Calories:"                   <-- Displays the text "Calories:"
:Disp C                             <-- Displays the amount of calories.
:Pause                              <-- Waits for the user to press (ENTER).
:Stop                               <-- Ends the program and displays the text "Done".

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.