Problem 167751 · easy · Level 01 Prerequisites & Setup

Receipt Total with Tax

input · arithmetic · f-strings · rounding · type conversion

A shop receipt has one item. Read the unit price (a decimal number) on the first line and the quantity (a whole number) on the second line. Sales tax is 8% of the subtotal. Print three lines:

Subtotal: $<subtotal>
Tax: $<tax>
Total: $<total>

Every amount must be shown with exactly two decimal places. Work out the tax and the total from the exact (unrounded) amounts and round only when printing, so the printed total can be a cent away from the printed subtotal plus the printed tax.

Examples

Input:
12.50
3
Output:
Subtotal: $37.50
Tax: $3.00
Total: $40.50
Input:
1.449
1
Output:
Subtotal: $1.45
Tax: $0.12
Total: $1.56
Explanation: the exact total is 1.449 + 0.11592 = 1.56492, which prints as 1.56 (adding the printed 1.45 and 0.12 would give 1.57).

Constraints

  • 0 <= price <= 10000, 0 <= quantity <= 1000

Goals

  • Convert input text to float and int
  • Compute a percentage of a value
  • Format money with exactly two decimals
Starting Python…