Oscar A.

asked • 04/27/20

Online shopping cart

(1) Create three files to submit:

  1. ItemToPurchase.h - Class declaration
  2. ItemToPurchase.cpp - Class definition
  3. main.cpp - main() function

Build the ItemToPurchase class with the following specifications:

  1. Default constructor
  2. Public class functions (mutators & accessors)
  3. SetName() & GetName() (2 pts)
  4. SetPrice() & GetPrice() (2 pts)
  5. SetQuantity() & GetQuantity() (2 pts)
  6. Private data members
  7. string itemName - Initialized in default constructor to "none"
  8. int itemPrice - Initialized in default constructor to 0
  9. int itemQuantity - Initialized in default constructor to 0

(2) In main(), prompt the user for two items and create two objects of the ItemToPurchase class. Before prompting for the second item, call cin.ignore() to allow the user to input a new string. (2 pts)


Ex:

Item 1
Enter the item name:
Chocolate Chips
Enter the item price:
3
Enter the item quantity:
1

Item 2
Enter the item name:
Bottled Water
Enter the item price:
1
Enter the item quantity:
10


(3) Add the costs of the two items together and output the total cost. (2 pts)


Ex:

TOTAL COST
Chocolate Chips 1 @ $3 = $3
Bottled Water 10 @ $1 = $10

Total: $13


1 Expert Answer

By:

Patrick B. answered • 04/27/20

Tutor
4.7 (31)

Math and computer tutor/teacher

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.