Question: Nested Structs and Pointer to Structs 1 . Declare a struct called ItemInfo that contains: c - string itemName, c - string itemID, and double
Nested Structs and Pointer to Structs
Declare a struct called ItemInfo that contains: cstring itemName, cstring itemID, and double price
Struct Itner Info& Cstring itemName
Declare a struct called ShoppingCart that contains: cstring shopperName, ItemInfo
item int itemCount and double total
Allocate memory on the heap dynamically allocate memory for a ShoppingCart struct. The item pointer should point to nullptr.
Write a function addtoCart that adds an item to the shoppingCart you can decide the arguments list and return values from the function Note: you need to get user input for the item info struct and the quantity that are added to the cart's item array. Use the itemCount array to store the quantity. That is the parallel arrays item holds the item info and the itemCount array holds the quantity number. Make sure to allocate memory for the item and i temCount. Keep provisions for any kind of memory expansion you may require, Use pointer notation.
Write a function removeFromCart that removes an item from the shoppinCart. You might be deleting the item from the shoppingCart or updating the quantity. Make provisions in case the item is being deleted. Use pointer notation.
Write a function calcTotal that takes the shoppingCart struct as an argument, calculates and returns the total amount that the shopper has to pay at checkout. Assume the arrays item and itemCount are previously populated. Use pointer notation.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
