|
| 1 | +""" |
| 2 | +The fruit shop operates at the following prices on working days: |
| 3 | +
|
| 4 | +fruit banana apple orange grapefruit kiwi pineapple grapes |
| 5 | +price 2.50 1.20 0.85 1.45 2.70 5.50 3.85 |
| 6 | +
|
| 7 | +On Saturdays and Sundays, the store operates at higher prices: |
| 8 | +
|
| 9 | +fruit banana apple orange grapefruit kiwi pineapple grapes |
| 10 | +price 2.70 1.25 0.90 1.60 3.00 5.60 4.20 |
| 11 | +
|
| 12 | +Write a program that reads from the console the following three variables entered by |
| 13 | + the user and calculates the price according to the prices in the tables above: |
| 14 | +
|
| 15 | +• fruit - banana / apple / orange / grapefruit / kiwi / pineapple / grapes; |
| 16 | +• day of the week - Monday / Tuesday / Wednesday / Thursday / Friday / Saturday / Sunday; |
| 17 | +• quantity (real number). |
| 18 | +
|
| 19 | +Print the result rounded to 2 decimal places. For an invalid day of the week or an invalid fruit name, print "error". |
| 20 | +""" |
| 21 | + |
| 22 | +fruit = input() |
| 23 | +day = input() |
| 24 | +quantity = float(input()) |
| 25 | + |
| 26 | +price = 0 |
| 27 | + |
| 28 | +if day in "Monday" "Tuesday" "Wednesday" "Thursday" "Friday" \ |
| 29 | + and fruit in "banana" "apple" "orange" "grapefruit" "kiwi" "pineapple" "grapes": |
| 30 | + if fruit == "banana": |
| 31 | + price = 2.50 |
| 32 | + elif fruit == "apple": |
| 33 | + price = 1.20 |
| 34 | + elif fruit == "orange": |
| 35 | + price = 0.85 |
| 36 | + elif fruit == "grapefruit": |
| 37 | + price = 1.45 |
| 38 | + elif fruit == "kiwi": |
| 39 | + price = 2.70 |
| 40 | + elif fruit == "pineapple": |
| 41 | + price = 5.50 |
| 42 | + elif fruit == "grapes": |
| 43 | + price = 3.85 |
| 44 | + |
| 45 | + final_price = price * quantity |
| 46 | + print(f"{final_price:.2f}") |
| 47 | + |
| 48 | +elif day in "Saturday" "Sunday" \ |
| 49 | + and fruit in "banana" "apple" "orange" "grapefruit" "kiwi" "pineapple" "grapes": |
| 50 | + if fruit == "banana": |
| 51 | + price = 2.70 |
| 52 | + elif fruit == "apple": |
| 53 | + price = 1.25 |
| 54 | + elif fruit == "orange": |
| 55 | + price = 0.90 |
| 56 | + elif fruit == "grapefruit": |
| 57 | + price = 1.60 |
| 58 | + elif fruit == "kiwi": |
| 59 | + price = 3.00 |
| 60 | + elif fruit == "pineapple": |
| 61 | + price = 5.60 |
| 62 | + elif fruit == "grapes": |
| 63 | + price = 4.20 |
| 64 | + |
| 65 | + final_price = price * quantity |
| 66 | + print(f"{final_price:.2f}") |
| 67 | + |
| 68 | +else: |
| 69 | + print("error") |
0 commit comments