In: Computer Science
A small tea at a certain shop costs 5QR and large tea are 15QR. Write a python program that asks the user to enter the price paid for orders. When the user enters -1 the program will display the number of small tea ordered, the number of the large tea ordered, and the total cost of large tea sold.
Sample Run:
Price Paid? 5
Price Paid? 15
Price Paid? 5
Price Paid? 5
Price Paid? 15
Price Paid? -1
There were 3 small cups of tea.
There were 2 small cups of tea.
The total cost of all large tea was 30 QAR.
(using sentinel loop)
Below is the python code:
---------------------------------------------------------------------
small = 0
large = 0
while True:
print("Price Paid?", end='')
inputValue = int(input())
if inputValue == 5:
small = small + 1
elif inputValue == 15:
large = large + 1
elif inputValue == -1:
if small > 0:
print("There were", small, "small cups of tea")
if large > 0:
print("There were", large, "large cups of tea")
print("The total cost of large tree was", large*15, "QAR.")
break
---------------------------------------------------------------------------------
Code screenshot:
Output Screenshot:
Kindly upvote if you find this answer helpful. Thanks