Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I already have the code from the first part of this assignment, I just need the following listed here to be added onto this code.
I already have the code from the first part of this assignment, I just need the following listed here to be added onto this code. C++ please!! This is the second part of the assignment that I need to be apart of my code. Please make changes according to the following:
1. Dynamic Memory You no longer know how many items are in the inventory file. You now have to be able to accept any number of items. When the program is graded they inventory list will be in the same format but the number of items in the list will be unknown until after your program is running.
a. The first item in the inventory file is the number of items in the list. Read in the first line and create a dynamic memory based upon this number.
b. Instead of using arrays you should use structs to store the data.
c. You need to update your search function to work with the new dynamic data.
2. You need to create a shopping cart for the user. Use a data structure of your choice to store what the user has selected to purchase. Remember the user can add as many items to their cart as there are in the inventory list.
a. You need to be able to search through the shopping cart.
b. If a person enters in a duplicate item that is already in the cart then it should increase the qty in the cart. You need to make sure that you have enough inventory to support the change.
c. Do not worry right now about the user removing anything in the cart.
d. Add in a function that prints the customers cart out. Anytime a user types cart when entering items your program should print the user current contents of the cart.
3. Prepare for the next customer by updating the inventory file. After the customer is done shopping you need to update the inventory file so that it matches the new qtys of items left in inventory.
a. The file should be the same name and same format as when you first loaded the file.
b. Remember to put as the first line the number of items in the inventory.
Remember to delete any allocated memory at the correct times of your program!.
My code is in the pictures!!!
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started