Python Forum
Help with my assingment please !!
Thread Rating:
  • 3 Vote(s) - 2.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help with my assingment please !!
#1
Output:
Enter 1 to start a new sale Enter 2 to view the total of all sales Enter 3 to view the total tax collected Enter 4 to view the quantity of each item sold Enter 5 to view the average $ of all the transactions Enter 6 to quit the program Enter A for an apple sales Enter G for a gas sale Enter C for cookie sales Enter Q to end the transaction and see the subtotal and total The market sells only a few items: Apples @ 99 cents each Gas @ $3.59 per gallon Cookies @ $1.99 per package (taxed) Gum @ 99 cents per package (taxed) Allow the user to keep entering in items until Q is entered. Calculate the subtotal for the transaction without tax. Calculate the total after adding 7% tax to the taxed items (see above). Display the subtotal and total. Keep a cumulative total of the quantity of each item sold. Keep a record of each of the transactions. After the user enters "Q" and quits the transaction, return to the main menu. Allow the user to view the total of all the sales (including tax), the total tax collected, the quantity of each item sold and the average sale (including tax). When the user enters 6, the program ends.
This is what I have so far but I can't figure how to plot the corresponding numbers or letters plus the grand total.

print("Enter 1 to start a new sale.")
print("Enter 2 to view the total of all sales.")
print("Enter 3 to view the total tax collected.")
print("Enter 4 to view the quantity of each item sold.")
print("Enter 5 to view the average $ of all the transactions.")
print("Enter 6 to quit the program.")
print("Enter A for an apple sales: ")
print("Enter G for a gas sale")
print("Enter C for cookie sales.")
print("Enter Q to end the transaction and see the subtotal and total.")


grocery_item = {}

grocery_history =[]

tax_item =()

stop = False

while not stop:
    name = input("Item name:\n")
    
    quantity = input("quatity purchased:\n")
    
    cost = input("price per item:\n")
    
    tax_item = input("items with tax gum, cookie:\n")
    
    grocery_item = {"item name" :name, "quantity" :int(quantity), "cost" :float(cost), "tax" :floa(tax_item)}
    
    grocery_history.append(grocery_item)
    
    response = input("Do you need another item?\n 'y' for yes or 'q' to quit:\n")
    
    if response == 'q':
        stop = True
                     
grand_total = 0
                     

for item in grocery_history:
    
    item_total = int(quantity) * float(cost) * float(tax_item)
    
    grand_total += item_total
                     
    print(quantity, name, cost, tax_item, item_total)
          
    item_total = 0       
          
print("Grand total: ", grand_total)
Reply
#2
Item name:
Apple
quatity purchased:
1
price per item:
12.99
items with tax gum, cookie:
0.00
Do you need another item?
 'y' for yes or 'q' to quit:
q
1 Apple 12.99 [error]0.00 0.0
Grand total:  0.0[/error]
Reply
#3
Please don't PM people your questions. I took a look at yours. I have no idea what's going on with it, or I would have answered it. Can you simplify your question as much as possible?

You shouldn't need to post more than 5-10 lines. Remove any input() calls and just assign the variables to the values that reproduce your problem, and similarly if there is preceding code, hard-code any results from it to keep things small. The code should be runnable. With that, the expected output, and actual output (that the code you provide produces) it'll be a great deal easier to help.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020