#C11380. Calculate Discounted Price

    ID: 40690 Type: Default 1000ms 256MiB

Calculate Discounted Price

Calculate Discounted Price

You are given a fruit type and an associated integer value. Depending on the fruit type, this value represents either a price (for apples) or a quantity (for oranges and bananas). You must calculate the final price after applying a special discount, defined as follows:

  • For apple: The final price is \(P = 0.8 \times V\) (i.e. a 20% discount on the given price).
  • For orange: The value \(V\) represents the quantity and every pair costs 50. If there is an odd number, the extra orange also costs 50. Formally, \(P = \Big(\lfloor V/2 \rfloor + (V \bmod 2)\Big) \times 50\).
  • For banana: The value \(V\) represents the quantity and the price is computed as \(P = 10 \times V - 5 \times \lfloor V/2 \rfloor\).

If an invalid fruit type is provided, your program should raise an error.

inputFormat

The input is read from standard input (stdin) and consists of multiple lines. The first line contains one integer \(T\), representing the number of test cases. Each of the following \(T\) lines contains a test case with two values: a string representing the fruit type and an integer value. The two values are separated by a space.

Example:

3
apple 100
orange 5
banana 10

outputFormat

For each test case, print the calculated discounted price on a new line to standard output (stdout).

Example Output:

80
150
75
## sample
3
apple 100
orange 5
banana 10
80

150 75

</p>