Question

In: Computer Science

Create a Python program that: Creates a sales receipt, displays the receipt entries and totals, and...

Create a Python program that:

  • Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file
    • Prompt the user to enter the
      • Item Name
      • Item Quantity
      • Item Price
    • Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made
    • Save the item name, quantity, item price, and extended price to a file
      • When you create the file, prompt the user for the name they want to give the file
      • Separate the items saved with commas
      • Each entry should be on a separate line in the text file
    • Ask the user if they have more items to enter
  • Once the user has finished entering items
    • Close the file with the items entered
    • Display the sales total
    • If the sales total is more than $100
      • Calculate and display a 10% discount
    • Calculate and display the sales tax using 8% as the sales tax rate
      • The sales tax should be calculated on the sales total after the discount
    • Display the total for the sales receipt

Save the program and submit it to this site for grading.

Solutions

Expert Solution

SOLUTION-
I have solve the problem in python code with comments and screenshot for easy understanding :)

CODE-

#python code
#Main function
def main():
    #Empty list
    l=[]
    #taking inputs from user
    name=input("Enter item name:")
    quantity=int(input("Enter item quantity:"))
    price=float(input("Enter item price:"))
    #Printing all details of item
    print("name= ",name)
    print("Quantity= ",quantity)
    print("Price= ",price)
    #Calculating and displaying extended price=quantity*price
    e=quantity*price
    #storing extended price of each item in list
    l.append(e)
    print("Extended price= ",e)
    #Taking name of the file as input from user
    f_name=input("Enter the filename in which you want to save data...")
    #opening that file in write mode as calculation is done only on the item
    # stored in one execution of program
  
    file=open("{}.txt".format(f_name),'w')
    #While loop
    while(1):
        #Storing all the details of item in that file with , in between
        file.write(name+",")
        file.write(str(quantity)+",")
        file.write(str(price)+",")
        file.write(str(e)+"\n")
        #Asking user if they wants to add more items
        i=input("Do you want to add more items?(y/n)")
        #if yes then again take input of all details of the items and
        #storing it in file in next iteration of loop as the loop continues
        if(i=="y" or i=="Y"):
            name=input("Enter item name:")
            quantity=int(input("Enter item quantity:"))
            price=float(input("Enter item price:"))
            print("name= ",name)
            print("Quantity= ",quantity)
            print("Price= ",price)
            e=quantity*price
            l.append(e)
            print("Extended price= ",e)
        #otherwise close the file and come out of loop
        elif(i=="n" or i=="N"):
            file.close()
            break
    #Printing total sales stored in that list l
    print("Sales total= ",sum(l))
    #if total sales >$100
    if(sum(l)>100):
        a=sum(l)
        #10% discount
        dis=a/10
        #sales after discount
        sales=a-dis
        #printing discount
        print("Discount= ",dis)
        #8% sales tax on the sale after discount
        sales_tax=sales*8/100
        #printing sales tax
        print("Sales Tax= ",sales_tax)
        #Total sale after discount and sales tax addition
        s=sales+sales_tax
        #Displaying final sales
        print("Total sales after discount and sales tax addition = ",s)
#calling main function
main()


SCREENSHOT-

f.txt -

OUTPUT -


IF YOU HAVE ANY DOUBT PLEASE COMMENT DOWN BELOW I WILL SOLVE IT FOR YOU:)
----------------PLEASE RATE THE ANSWER-----------THANK YOU!!!!!!!!----------


Related Solutions

Create a python program that: Creates a sales receipt, displays the receipt entries and totals, and...
Create a python program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves...
Create a program that: Creates a sales receipt, displays the receipt entries and totals, and saves the receipt entries to a file Prompt the user to enter the Item Name Item Quantity Item Price Display the item name, the quantity, and item price, and the extended price (Item Quantity multiplied by Item Price) after the entry is made Save the item name, quantity, item price, and extended price to a file When you create the file, prompt the user for...
IN PYTHON: Write a program that displays the lines from the total.txt file in the following...
IN PYTHON: Write a program that displays the lines from the total.txt file in the following output. Use a try catch phrase to check for errors. Use only one function for this portion [main()]. Remember to use Python. Sample output below: 19 16, 29 3, 30 4, 34
The code that creates this program using Python: Your program must include: You will generate a...
The code that creates this program using Python: Your program must include: You will generate a random number between 1 and 100 You will repeatedly ask the user to guess a number between 1 and 100 until they guess the random number. When their guess is too high – let them know When their guess is too low – let them know If they use more than 5 guesses, tell them they lose, you only get 5 guesses. And stop...
In this exercise, you will create a program that displays the amount of a cable bill....
In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer, as shown in Figure 10-30. For a residential cus- tomer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. If necessary, create a...
In this exercise, you will create a program that displays the amount of a cable bill....
In this exercise, you will create a program that displays the amount of a cable bill. The amount is based on the type of customer shown in figure 10-30. For a residential customer, the user will need to enter the number of premium channels only. For a business customer, the user will need to enter the number of connections and the number of premium channels. Use a separate void function for each customer type. Enter your C++ instructions into the...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program:...
Create a Python script in IDLE or Kali Python3 CLI to create the following Python Program: Your program will create a username of your choice using a Kali Linux command "useradd -m mark", then set the password for that user using the Kali Linux Command "echo "mark:10101111" | chpasswd". Then you create a dictionary file using the Kali Linux command "crunch 8 8 01 > mylist.txt" Your python script should crack the password for that user and display on the...
Create a program that creates a sorted list from a data file. The program will prompt...
Create a program that creates a sorted list from a data file. The program will prompt the user for the name of the data file. Create a class object called group that contains a First Name, Last Name, and Age. Your main() function should declare an array of up to 20 group objects, and load each line from the input file into an object in the array. The group class should have the following private data elements: first name ,last...
Using python Write a program that displays all of states in the U.S. and display each...
Using python Write a program that displays all of states in the U.S. and display each state that begins with the letter A.
write a python program that inputs 10 integer values from the keyboard and then displays their...
write a python program that inputs 10 integer values from the keyboard and then displays their sum. use for loop
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT