weekly coding P2
Sat Jan 14 2023 14:29:14 GMT+0000 (UTC)
Saved by
@Shaghaf_2000
#python
# Weekly coding exercise:
"""
Thisprogram will calculate the tip and cost of the meal
to be split between griends at a restaurant.
Take three inputs:
1. Total price of the meal
2. The percentage of tip to be given
3. The number of friends to split the cost by
"""
totalPrice= float(input("Enter the total price of the meal: "))
tip= float(input("Enter the the percentage of the tip to be given in (of 100): "))
friends= float(input("Enter the number of friends to split the bill by: "))
if tip>=totalPrice:
print("Invalid tip or invalid meal price")
elif tip>100 or tip<0:
print("Invalid tip")
elif friends<2:
print("Need more friends to split the bill by")
else:
# calculate tip:
calculateTip= (totalPrice)*(tip/100)
# add tip to the price:
mealTip = (totalPrice)+(calculateTip)
print(f"The meal total (with tip) is ${mealTip}")
person = (mealTip)/(friends)
print(f"Each person should pay ${round(person,2)}")
content_copyCOPY
Comments