Question: Write a program that reads grocery product records from a file, then store the information in an array of structures. Each grocery product record consists



Write a program that reads grocery product records from a file, then store the information in an array of structures. Each grocery product record consists of the following 5 items PLU code: Product Look Up Code. Unique for each product, stored as a string - Product Name, stored as a string - Product Sales Type: 0 per unit, 1- per pound Price per Pound or price per unit, - Current Inventory Level (pounds or units) Below is an example of file content. In this example, there are four records, and each line corresponds to a record A001 Apples 1 0.90 21 A002 Peaches 1 0.82 11 A006 Avocados 0 1.54 27 A008 Mangos 0 1.69 19 Your program should do the following Declare a Product structure to hold the items. There should be one structure member for each item in the product record Read the file to determine the number of records in the file Dynamically allocate an array of Product structures, with the appropriate size, and populate the array with the items from the file Then the program should print the inventory as read from the file, and loops over displaying a menu for the user to choose from 1- Checkout 2 Print current inventory 3-Quit Checkout If the user chooses checkout, the user can purchase multiple products in each checkout. The user is asked to enter the PLU code, then the quantity (weight or # of units, depending on the sales type) for each product. The program keeps up with the total cost (S). The user can enter "O" for a PLU to indicate the end of checkout. The program then displays the total price, and displays the menu again. The program should do input validation (quantity must be positive). Your program should make sure the quantity bought is not more than the inventory level. For example, if the user wants to buy 10 apples, but only 5 Write a program that reads grocery product records from a file, then store the information in an array of structures. Each grocery product record consists of the following 5 items PLU code: Product Look Up Code. Unique for each product, stored as a string - Product Name, stored as a string - Product Sales Type: 0 per unit, 1- per pound Price per Pound or price per unit, - Current Inventory Level (pounds or units) Below is an example of file content. In this example, there are four records, and each line corresponds to a record A001 Apples 1 0.90 21 A002 Peaches 1 0.82 11 A006 Avocados 0 1.54 27 A008 Mangos 0 1.69 19 Your program should do the following Declare a Product structure to hold the items. There should be one structure member for each item in the product record Read the file to determine the number of records in the file Dynamically allocate an array of Product structures, with the appropriate size, and populate the array with the items from the file Then the program should print the inventory as read from the file, and loops over displaying a menu for the user to choose from 1- Checkout 2 Print current inventory 3-Quit Checkout If the user chooses checkout, the user can purchase multiple products in each checkout. The user is asked to enter the PLU code, then the quantity (weight or # of units, depending on the sales type) for each product. The program keeps up with the total cost (S). The user can enter "O" for a PLU to indicate the end of checkout. The program then displays the total price, and displays the menu again. The program should do input validation (quantity must be positive). Your program should make sure the quantity bought is not more than the inventory level. For example, if the user wants to buy 10 apples, but only 5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
