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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

This is a python File

Create a program that presents a menu with these options:

  1. Add product

  2. Sort by quantity (low to high)

  3. Print Inventory

  4. 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

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Linux
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education