Lesson goal: Calculating a tip (with keyboard input)

Previous: Calculate a tip | Home | Next: Distance formula with variables

The tip calculator can be enhanced by asking the user the the meal cost and desired tip using input from the keyboard. You might want to review the input function from an earlier lesson. Here's the base code for doing the tip calculator with some interaction from the user (remember that $tip=per/100\times meal$ given that $per$ and $meal$ are the percentage of tip to leave and cost of the meal, respectively).

Now you try. Try finishing this tip calculator by finishing in the tip= line.

Type your code here:

See your results here:

Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.