Question

Capture the following scenario using python. In a restaurant, there is a table with five people...

Capture the following scenario using python.

In a restaurant, there is a table with five people dining together.

They order the following:

Seat 1 $13.50

Seat 2 $12.00

Seat 3=$14.64

Seat 4=$22.70

Seat5=$16.73

Appetizer1=$9.99.


The waitress sends them a total bill only to realize that they want separate bills and appetizer is only shared by seats1,2 and 3.

The sales tax is 5%.

Write the code to calculate the total bill and then the code to split the bill as explained.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Code:

Code as text:

# cost of order of each seats (in $)

seat1 = 13.50

seat2 = 12.00

seat3 = 14.64

seat4 = 22.70

seat5 = 16.73

appetizer = 9.99 #cost of appetizer

tax = 0.05 #sales tax is 5% = 0.05

order_total = seat1 + seat2 + seat3 + seat4 + seat5

total_bill = order_total + (tax * order_total)

print("Total bill: $%.2f" % (total_bill))

#correcting bill

shared_bill = appetizer / 3 #appetizer is shared by 1, 2, 3

# calculating bill

bill1 = (seat1 + shared_bill) * (1 + tax)

bill2 = (seat2 + shared_bill) * (1 + tax)

bill3 = (seat3 + shared_bill) * (1 + tax)

bill4 = seat4 * (1 + tax)

bill5 = seat5 * (1 + tax)

print("Splitted bill is: ")

print("Seat 1: $%.2f" % (bill1))

print("Seat 2: $%.2f" % (bill2))

print("Seat 3: $%.2f" % (bill3))

print("Seat 4: $%.2f" % (bill4))

print("Seat 5: $%.2f" % (bill5))

Sample run:

P.s. ask any doubts in comments and don't forget to rate the answer

Add a comment
Know the answer?
Add Answer to:
Capture the following scenario using python. In a restaurant, there is a table with five people...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • How can we assess whether a project is a success or a failure? This case presents...

    How can we assess whether a project is a success or a failure? This case presents two phases of a large business transformation project involving the implementation of an ERP system with the aim of creating an integrated company. The case illustrates some of the challenges associated with integration. It also presents the obstacles facing companies that undertake projects involving large information technology projects. Bombardier and Its Environment Joseph-Armand Bombardier was 15 years old when he built his first snowmobile...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT