This is a python File Create a program that presents a menu with these options: Add product Sort by quantity (low to high) Print Inventory Quit Read the initial product information from a text file. Remember to ask the user to enter the filename & make sure it exists! The program should NOT product an error if the file isn’t there! Store the product information into a DICTIONARY called prodDict. The dictionary should map the productID (the key for the dictionary) to a LIST that contains description, unitPrice, and quantity. The text file will be structured as shown below, where each line contains the product id, product description, unitPrice and quantity. NOTE: Each entry on the line is separated by a comma and a space. Example textfile: 111, arm chair, 99.99, 5 444, desk, 10, 40 777, lamp, 20, 5 333, credenza, 50.98., 20 222,bassinet , 5.59, 10 Example of the empDict after the information shown has been readd and stored: { 111: [“George Gray”, 10, 40], 222: [“Amy Abrahmson”, 10,30], 333: [“David Dell”, 10, 42], 444:[“Bob Brown”,5,40] } The program must contain the following functions – make sure the name of the function is exactly as shown and that it accepts the parameters shown: createMenu(optionList, menuTitle) returns a string getValidChoice(numOptions, menuStr) returns an integer addProduct(prodDict) doesn’t return anything – dictionaries are passed on a two-way street (by reference) asks the user to enter id, description, unitPrice, and quantity stores the information into the prodDict printReport(prodDict) doesn’t return anything. Simply prints a report calculates totalCost at the end of the report, prints the grand total showing the value of all of the products in the inventory Example of the report for the data shown: 111, arm chair, 90.99, 5 444, desk, 10, 40 777, lamp, 20, 5 333, credenza, 50.98., 20 222,bassinet , 5.50, 10 Product Roster ID Description Unit Price Quantity TotalCost ==================================================================== 111 arm chair $99.99 40 $ 499.95 444 desk $10.00 40 $ 400.00 777 lamp $20.00 5 $ 100.00 333 credenza $50.98 20 $1019.60 222 bassinet $ 5.50 10 $ 50.00 Grand Total: $2069.55 Example of the report for the data if option 2 was selected (sort by quantity): Product Roster ID Description Unit Price Quantity TotalCost ==================================================================== 777 lamp $20.00 5 $ 100.00 222 bassinet $ 5.50 10 $ 50.00 333 credenza $50.98 20 $1019.60 111 arm chair $99.99 40 $ 499.95 444 desk $10.00 40 $ 400.00 Grand Total: $2069.55
This is a python File
Create a program that presents a menu with these options:
-
Add product
-
Sort by quantity (low to high)
-
Print Inventory
-
Quit
Read the initial product information from a text file.
Remember to ask the user to enter the filename & make sure it exists! The program should NOT product an error if the file isn’t there!
Store the product information into a DICTIONARY called prodDict. The dictionary should map the productID (the key for the dictionary) to a LIST that contains description, unitPrice, and quantity.
The text file will be structured as shown below, where each line contains the product id, product description, unitPrice and quantity.
NOTE: Each entry on the line is separated by a comma and a space.
Example textfile:
111, arm chair, 99.99, 5
444, desk, 10, 40
777, lamp, 20, 5
333, credenza, 50.98., 20
222,bassinet , 5.59, 10
Example of the empDict after the information shown has been readd and stored:
{ 111: [“George Gray”, 10, 40], 222: [“Amy Abrahmson”, 10,30], 333: [“David Dell”, 10, 42], 444:[“Bob Brown”,5,40] }
The program must contain the following functions – make sure the name of the function is exactly as shown and that it accepts the parameters shown:
-
createMenu(optionList, menuTitle) returns a string
-
getValidChoice(numOptions, menuStr) returns an integer
-
addProduct(prodDict) doesn’t return anything –
dictionaries are passed on a two-way street (by reference)
asks the user to enter id, description, unitPrice, and quantity
stores the information into the prodDict -
printReport(prodDict) doesn’t return anything. Simply prints a report
calculates totalCost -
at the end of the report, prints the grand total showing the value of all of the products in the inventory
Example of the report for the data shown:
111, arm chair, 90.99, 5
444, desk, 10, 40
777, lamp, 20, 5
333, credenza, 50.98., 20
222,bassinet , 5.50, 10
Product Roster
ID Description Unit Price Quantity TotalCost
====================================================================
111 arm chair $99.99 40 $ 499.95
444 desk $10.00 40 $ 400.00
777 lamp $20.00 5 $ 100.00
333 credenza $50.98 20 $1019.60
222 bassinet $ 5.50 10 $ 50.00
Grand Total: $2069.55
Example of the report for the data if option 2 was selected (sort by quantity):
Product Roster
ID Description Unit Price Quantity TotalCost
====================================================================
777 lamp $20.00 5 $ 100.00
222 bassinet $ 5.50 10 $ 50.00
333 credenza $50.98 20 $1019.60
111 arm chair $99.99 40 $ 499.95
444 desk $10.00 40 $ 400.00
Grand Total: $2069.55

Trending now
This is a popular solution!
Step by step
Solved in 2 steps









