Question: Write a modularized, menu-driven program to read a file with an unknown number of inventory records using an array of structs/objects and an array of
Write a modularized, menu-driven program to read a file with an unknown number of inventory records using an array of structs/objects and an array of pointers.
- An item may have three statuses: active, discontinued, or recalled
- Menu (use a switch statement) options to
- print all items in the inventory unsorted
- print invalid records from an error file
- print all items in the inventory sorted in ascending order; you should allow a user to sort by any field: item ID, item name (one word), quantity on hand, or price.
- print all "active" items
- print all "discontinued" items
- print all "recalled" items
- search for an item by ID or name
- change status
- print a report with the following details
- number of unique items in the inventory
- the total worth of the inventory and the total count of all items in the inventory
- quit the program
- A user should be able to run many as many times as the user wants; print the menu every time
- Implement the menu as a switch statement using enum
- All items are unique
- Record
- Item Id must be 5 characters long; maybe alpha-numeric
- The name may contain only alpha characters
- Quantity and price must be zero (a promotional item, an item is not in stock) or above
- status value is not in the input file
- Reading from the input file and storing the records
- The input file has an unknown number of records of inventory items;
- one record per line in the following order: item ID, item name (one word), quantity on hand, and a price;
- All fields in the input file are separated by a tab (\t) or a blank (up to you)
- the input file may be empty or has more records that your array can store- output the appropriate messages to the user.
- check for the array boundaries when storing the records
- Only go through the file once
- Do not read the file once to count the number of the records, close it, and then read it again
- Store all invalid records along with the error messages in a separate file
- Use an array of structs if you do not know how to write classes yet. Use classes if you have completed CS 216 or similar; do not store bad records in the array of records
- read a record into a temp struct; error check the record and only store the record in the array of records if it is valid
- assign "active" status when storing the item in the array of structs/objects
- use enum to store the item status
- Sorting
- Write one function, that can sort by any field using a parallel array of pointers
- Do not copy and paste sort code five times into the same function. Bubble sort is the easiest to modify.
- sorting using pointers is faster because you have to swap pointers only, which are normally stored in 4 bytes; it also allows you to preserve the original order of the items
- submenu for sorting options is optional
- if you create a submenu to sort by various fields, add an option to go back to the main menu without being forced to sort
- Searching
- a user should be able to enter the name of the item using any case, (for example, sTRolleR)
- You may wish to store items in all lower/upper case to expedite the search
- write one search function that can search by ID and name and goes through the array of structs/objects only once
- the search function should return the item subscript- you will reuse the function to "recall" an item
- Printing all, active, recalled, and the discontinued items
- write one function that can print items based on their status
Programming language is C++ please
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
