
Andrew N.
asked 26dCollege level Python
Write a Python program for a grocery store to keep track of the fruits and prices in the store. The manager can enter a fruit’s name, followed by its prices in one line. A comma should separate the fruit and the fruit’s prices. Each fruit in this shop should have at least three prices based on the quality of the fruit. Your program should print a main menu for the store to allow her to add, edit, delete, or search an item.
Note 1: The delete option has two features: delete all the items, or delete one item at a time.
Note 2: If one item is not in stock and the store is trying to edit, delete, or search it, your program should return a message to the store with the name of the fruit.
Note 3: Your program should keep running until the user quits.
Note 4: The program should print the up-to-date stock at the end of every option selected from the menu (The name of the fruit is a string and prices are a list of float numbers).
Example:
(a) The program prints the main menu.
(b) The user chooses a number from the menu.
(c) A comma separates the fruit and the prices. The sample output showing the behavior of the program is on the next page.
1 Expert Answer
I do not have a python compiler. I use the online interpreter which CANNOT read from disk files..
(1)store the fruits and prices in a text file: fruits.dat
apples1 , 0.55
apples2, 0.45
apples3, 0.35
bananas1, 0.65
bananas2, 0.45
bananas3, 0.25
etc etc etc
(2) create a function which displays the menu and returns the selection that the user inputs;
loop until a valid selection in made
<1> INSERT//ADD NEW FRUIT
<2> DELETE FRUIT
<3> EDIT/UPDATE FRUIT
<4> SEARCH FOR FRUIT ITEM
input selection or ZER0 to QUIT
(3) reads the file into the dictionary
(4) call menu()
(5) while menuChoice != 0
updates the dictionary
writes to file
Still looking for help? Get the right answer, fast.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Patrick B.
26d