With this assignment you will start to learn how to write a practical menu drive
ID: 3647465 • Letter: W
Question
With this assignment you will start to learn how to write a practical menu driven program that manages a list of data. You will use an array of structs to organize the data and you will save the information in a text file.The assignment is to write a menu driven program that manages a small business inventory, or list.
The Menu commands must include:
A....Add a new entry
D....Delete an item from the list (inventory)
P....Display all records (on the screen/monitor)
S....Create a current report (save it to a file)
C....Clear all records
Q...Quit
You must add (1) additional menu option that you choose. It may be a menu option that allows the inventory to be modified. i.e. add inventory quantities, change price/cost, change dates, etc.
Explanation / Answer
1. structs ------------------- typedef struct rec { char item[100]; char manufacturer[100]; int productid; int quantity; double cost; double avg_inventory; }record; This is the structure(coded in C) with the valid fields given 2. As mentioned you will be using an array of such records( called 'inventory'). So you will be maintaining a integer variable index(initial 0) to maintain the current position of array input. When you enter new record you increase the value of index by 1 and remove one record means decreasing the index by 1. Index can be used to access the current empty array position. A. Add new entry. -------------------------- Just create a new record in variable 'temp' and preform, inventory[index] = temp; index++ B. Delete item from inventory ----------------------------------------- Just compare in a loop all records in the array 'inventory' to match with the desired item to delete(use strcmp). When it matched just, copy the last record (i.e inventory[index-1]) into that position and then decrease the index by 1. C. Display all records --------------------------- Just loop through the array( for(ctr=0; ctr 6 functions apart from this you can make smaller functions to take user choice from Menu and Inputting a Record and returning it. That way you can get desired min 8 functions. Also you can use (#define arrsize 25) as mentionedRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.