#K71727. Total Payment Calculator

    ID: 33596 Type: Default 1000ms 256MiB

Total Payment Calculator

Total Payment Calculator

You are given the number of pastries purchased n and the price per pastry p. The store provides discounts based on the number of pastries purchased as follows:

  • If n < 5: No discount.
  • If 5 ≤ n ≤ 10: 10% discount.
  • If 11 ≤ n ≤ 20: 20% discount.
  • If n > 20: 30% discount.

The final price is computed using the formula:

\(\text{Final Price} = n \times p \times (1 - d)\)

where \(d\) is the discount rate. The result must be rounded to two decimal places.

inputFormat

The input consists of two space-separated values. The first value is an integer (n) representing the number of pastries purchased, and the second value is a float (p) representing the price per pastry.

outputFormat

Output the total amount the customer has to pay after applying the discount. The result should be a float rounded to two decimal places.## sample

4 2.50
10.00