Question: In C(NOT C++) plz 7.7 LAB*: Program: Online shopping cart (Part 2) This program extends the earlier Online shopping cart program. (Consider first saving your

In C(NOT C++) plz

7.7 LAB*: Program: Online shopping cart (Part 2)

This program extends the earlier "Online shopping cart" program. (Consider first saving your earlier program).

(1) Extend the ItemToPurchase struct to contain a new data member. (2 pt)

  • char itemDescription[ ] - set to "none" in MakeItemBlank()

Implement the following related functions for the ItemToPurchase struct.

  • PrintItemDescription()
    • Has an ItemToPurchase parameter.

Ex. of PrintItemDescription() output:

Bottled Water: Deer Park, 12 oz. 

(2) Create three new files:

  • ShoppingCart.h - struct definition and related function declarations
  • ShoppingCart.c - related function definitions
  • main.c - main() function (Note: main()'s functionality differs from the warm up)

Build the ShoppingCart struct with the following data members and related functions. Note: Some can be function stubs (empty functions) initially, to be completed in later steps.

  • Data members (3 pts)
    • char customerName [ ]
    • char currentDate [ ]
    • ItemToPurchase cartItems [ ] - has a maximum of 10 slots (can hold up to 10 items of any quantity)
    • int cartSize - the number of filled slots in array cartItems [ ] (number of items in cart of any quantity)
  • Related functions
    • AddItem()
      • Adds an item to cartItems array. Has parameters ItemToPurchase and ShoppingCart. Returns ShoppingCart object.
    • RemoveItem()
      • Removes item from cartItems array (does not just set quantity to 0; removed item will not take up a slot in array). Has a char[ ](an item's name) and a ShoppingCart parameter. Returns ShoppingCart object.
      • If item name cannot be found, output this message: Item not found in cart. Nothing removed.
    • ModifyItem()
      • Modifies an item's description, price, and/or quantity. Has parameters ItemToPurchase and ShoppingCart. Returns ShoppingCart object.
    • GetNumItemsInCart() (2 pts)
      • Returns quantity of all items in cart. Has a ShoppingCart parameter.
    • GetCostOfCart() (2 pts)
      • Determines and returns the total cost of items in cart. Has a ShoppingCart parameter.
    • PrintTotal()
      • Outputs total of objects in cart. Has a ShoppingCart parameter.
      • If cart is empty, output this message: SHOPPING CART IS EMPTY
    • PrintDescriptions()
      • Outputs each item's description. Has a ShoppingCart parameter.

Ex. of PrintTotal() output:

John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats 2 Headphones 1 @ $128 = $128 Total: $521 

Ex. of PrintDescriptions() output:

John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats Headphones: Bluetooth headphones 

(3) In main(), prompt the user for a customer's name and today's date. Output the name and date. Create an object of type ShoppingCart. (1 pt) Ex:

Enter Customer's Name: John Doe Enter Today's Date: February 1, 2016 Customer Name: John Doe Today's Date: February 1, 2016 

(4) Implement the PrintMenu() function. PrintMenu() has a ShoppingCart parameter, and outputs a menu of options to manipulate the shopping cart. Each option is represented by a single character. Build and output the menu within the function.

If the an invalid character is entered, continue to prompt for a valid choice. Hint: Implement Quit before implementing other options. Call PrintMenu() in the main() function. Continue to execute the menu until the user enters q to Quit. (3 pts) Ex:

MENU a - Add item to cart r - Remove item from cart c - Change item quantity i - Output items' descriptions o - Output shopping cart q - Quit Choose an option: 

(5) Implement the "Output shopping cart" menu option. (3 pts) Ex:

OUTPUT SHOPPING CART John Doe's Shopping Cart - February 1, 2016 Number of Items: 8 Nike Romaleos 2 @ $189 = $378 Chocolate Chips 5 @ $3 = $15 Powerbeats Headphones 1 @ $128 = $128 Total: $521 

(6) Implement the "Output item's description" menu option. (2 pts) Ex:

OUTPUT ITEMS' DESCRIPTIONS John Doe's Shopping Cart - February 1, 2016 Item Descriptions Nike Romaleos: Volt color, Weightlifting shoes Chocolate Chips: Semi-sweet Powerbeats Headphones: Bluetooth headphones 

(7) Implement "Add item to cart" menu option. (3 pts) Ex:

ADD ITEM TO CART Enter the item name: Nike Romaleos Enter the item description: Volt color, Weightlifting shoes Enter the item price: 189 Enter the item quantity: 2 

(8) Implement the "Remove item from cart" menu option. (4 pts) Ex:

REMOVE ITEM FROM CART Enter name of item to remove: Chocolate Chips 

(9) Implement "Change item quantity" menu option. Hint: Make new ItemToPurchase object before using ModifyItem() function. (5 pts) Ex:

CHANGE ITEM QUANTITY Enter the item name: Nike Romaleos Enter the new quantity: 3 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!