Split the bill

Share a restaurant bill between friends, including a tip.

What to build

A program with three inputs of different types, several calculations and formatted output.

Requirements

  • Read the bill, the number of people and the tip percentage.
  • Print Tip: T, Total: A and Each pays: E, each with two decimal places.

Input

Three lines: the bill (may have decimals), the number of people (a whole number), and the tip percentage (a whole number).

Output

Three lines, as in the example.

Constraints

The bill is from 0 to 100000, there are from 1 to 100 people, and the tip is from 0 to 100.

Example

Input:

100
4
10

Output:

Tip: 10.00
Total: 110.00
Each pays: 27.50

Why it works

Naming each step, tip and total, keeps every line simple. People must be a whole number, which is why it is converted with int while the bill uses float.

Examples

Example 1 · Input
100
4
10
Expected output
Tip: 10.00
Total: 110.00
Each pays: 27.50
Example 2 · Input
80.50
2
0
Expected output
Tip: 0.00
Total: 80.50
Each pays: 40.25

Prompts inside input() are ignored when checking, so input("n: ") is fine.

Hints

Hint 1

Work out the tip from the bill first.

Hint 2

Each person pays (bill + tip) / people.

Hint 3

Read each line in the order the input gives it.

Solution

Show one correct solution (try it yourself first)
bill = float(input())
people = int(input())
percent = int(input())
tip = bill * percent / 100
total = bill + tip
print(f"Tip: {tip:.2f}")
print(f"Total: {total:.2f}")
print(f"Each pays: {total / people:.2f}")

Lesson: Input and type conversion →