Question
How do i do this with Python?

Create a script to make a receipt for a restaurant purchase. Your script should repeatedly take sales until the user hits a
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hello, here is the completed code you wanted. Every important statement is explained using comments. Please check and let me know if you have any doubts. Thanks.

I have compiled the program in python 3, If you need it in python 2 let me know

CODE

#inititalizing variables
subtotal = 0
tax = 0
tip = 0

#repeat until user hits d
while True:
   #propmt for sales
   sales = input("Enter Sales: ")
  
   #if sales equals d
   if sales == "d":
       break;
   #convert sales into float
   sales = float(sales)
  
   #calculating subtotal
   subtotal = subtotal + sales
  
   #calculating tax
   tax = tax + (sales * .06)
  
   #if sales less than 15
   if sales < 15:
       #calculating tip
       tip = tip + (sales * .1)
   #if sales greater than or equals 15 and less than or equals 50
   elif sales >= 15 and sales <=50:
       #calculating tip
       tip = tip + (sales * .15)
   #if sales greater than 50
   else:
       #calculating tip
       tip = tip + (sales * .2)
#calculating overall total
total = subtotal + tax + tip
  
#printing outputs
print("RESTAURANT")
print("----------")
print("Subtotal: "+"{0:.2f}".format(subtotal))
print("Tax: "+"{0:.2f}".format(tax))
print("Tip: "+"{0:.2f}".format(tip))
print("Total: "+"{0:.2f}".format(total))

OUTPUT

Enter Sales: 10 Enter Sales 20 Enter Sales 60 Enter Sales d RESTAURANT Subtotal: 90.00 Tax: 5.40 Tip: 16.00 Total: 111.40

CODE SCREEN SHOT

1 2 #inititalizing variables subtotal0 tax = 0 #repeat until user hits d while True: #propmt for sales sales input (Enter Sa38 #printing outputs 39 print (RESTAURANT) 40 41 print (Subtotal: +[0:.2f].format (subtotal)) 42 print (Tax:0:.2f). f

Add a comment
Know the answer?
Add Answer to:
Create a script to make a receipt for a restaurant purchase. Your script should repeatedly take s...
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
  • Create a new program in Mu and save it as ps2.4.1.py Take the code below and...

    Create a new program in Mu and save it as ps2.4.1.py Take the code below and fix it as indicated in the comments: dividend = 7 divisor = 3 # You may modify the lines of code above, but don't move them! # Your code should work with different values for the variables. # The variables above create a dividend and a divisor. Add # some code below that will print the quotient and remainder # of performing this operation....

  • Bill and Tip Calculator Write a C program to generate a receipt for a restaurant. Your...

    Bill and Tip Calculator Write a C program to generate a receipt for a restaurant. Your application should allow the user to enter the bill amount and allow them to decide if they would like to leave a 15 percent tip or not. ▪ Do not allow the user to enter a negative value for the bill. ▪ Display the bill amount, tax amount, tip amount, and total amount. ▪ To calculate the tip, multiply the bill amount by 0.15....

  • how to do this using python 10. Create a script to calculate the Eigen values and right Eigen vectors for a given matrix. Your script should get the dimensions of the matrix from the user first an...

    how to do this using python 10. Create a script to calculate the Eigen values and right Eigen vectors for a given matrix. Your script should get the dimensions of the matrix from the user first and verify that the matrix is square. If the dimensions don't represent a square matrix, your script should report an error and ask for the dimensions again. If the users doesn't give you enough values (or too many values) for the given dimensions, your...

  • I need help with this python programming exercise, please! thanks in advance Create a Python script...

    I need help with this python programming exercise, please! thanks in advance Create a Python script file called hw4.py. Add your name at the top as a comment, along with the class name and date. Both exercises should be in this file, with a comment before each of them to mark it. Ex. 1. Write a program that inputs an integer number from the user, then prints a letter "O" in ASCII art using a width of 5 and the...

  • Java I: Create a Java program that will accept the price of an item and the...

    Java I: Create a Java program that will accept the price of an item and the quantity being purchased of that item. After accepting the input, calculate the amount of the purchase (based on the price and quantity), calculate the sales tax on the purchase, then output the product price, quantity, subtotal, sales tax, and the total sale based on the output format shown below. Structure your file name and class name on the following pattern: The first three letters...

  • PYTHON3 code Each of you will create a cash register / point of sale for your...

    PYTHON3 code Each of you will create a cash register / point of sale for your favorite retail establishment (restaurant, store, website, etc..). The program should have a way to input an indefinite number of items (items, quantities, price); This should be stored as a list of lists in your program. It should generate a "receipt" - a list of items showing what you bought; It should generate a total amount spent including a tax computation. It should be written...

  • Your assignment is to create a restaurant ordering system where the cashier can create the menu...

    Your assignment is to create a restaurant ordering system where the cashier can create the menu and then take in the order and display the order back to the customer Sample Execution – Level 1 Welcome to your Menu Creation system. How many items would you like to have on your menu? 2 Create your menu! Enter item #1: Coffee Enter item #2: Tea This is the menu: Coffee Tea What would you like to order? Cake That isn’t on...

  • Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill...

    Java programming Create a simple tip calculator called TipCalcMethod. Your program should read in the bill amount from the command-line, then show 3 tip amounts: 15%, 20% and 25% of the bill. Don't worry about rounding the result to two decimal places, but make sure that the result includes cents (not just dollars). This program will be different than your first Tipcalc program because you will writea method to calculate the tip amount. program will have 2 methods: main) and...

  • 1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write...

    1. Create a Python script file called Assignment_Ch06-02_yourLastName.py. (Replace yourLastName with your last name.) 2. Write a Python program that prompts the user for a sentence, then replaces all the vowels in the sentence with an asterisk: '*' Your program should use/call your isVowel function from Assignment_Ch06-01. You can put the isVowel() function in a separate .py file, without the rest of the Ch06-01 code, and then import it. 6-01 CODE: def isVowel(x):     if x in "aeiouyAEIOUY":         return True     else:...

  • Urgent must be done in C# create an instance of the “ testquestion” class in your main method. al...

    Urgent must be done in C# create an instance of the “ testquestion” class in your main method. allow the uswr to enter the teat question and its answer, it they want to. if they do not, then continue by creating a default queatuon and answer. please use the constructor methods here. Then, using the “tostring or _str_method, have it print out those variables as decribed above. call the “check answer” method and allow the user to continue attempting to...

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