# 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)}")
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter