Lesson goal: Calculating a tip in a restaurant

Previous: Mathematical expressions with variables | Home | Next: Calculate a tip (with keyboard input)

With the use of variables in mathematical expressions, you can program the computer to do useful calculations for yourself. How about the tip in a restaurant? If you know the cost of a meal $(meal)$, and decide what percentage to leave the server $(per)$, the tip will be $tip=per/100\times meal$. With this, the total cost of the meal will be $total=meal+tip$. See if you can finish the code below, and have a "tip calculator."

Now you try. Try finishing this tip calculator based on the formulas discussed above.

Type your code here:

See your results here: