Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please write this in C++ with Classes. Please write the code in computer, with c

ID: 3868808 • Letter: P

Question

Please write this in C++ with Classes. Please write the code in computer, with comments and organization. (Not so advanced because it is for a class of data structures). Please implement the InventoryItem.h in this code.

17. Cásh Register Design a CashRegister class that can be used with the InventoryItem class discussed in this chapter. The CashRegister class should perform the following: 1. Ask the user for the item and quantity being purchased. 2. Get the item's cost from the InventoryItem object. 3. Add a 30% profit to the cost to get the item's unit price. 4. Multiply the unit price times the quantity being purchased to get the purchase sub- total. Compute a 6% sales tax on the subtotal to get the purchase total. 6. Display the purchase subtotal, tax, and total on the screen. 7. Subtract the quantity being purchased from the onHand variable of the InventoryItem class object. Implement both classes in a complete program. Feel free to modify the InventoryItem class in any way necessarv

Explanation / Answer

#include<iostream>
#iclude Inventory


class cashRegister {
private:
   InventoryItem** items;
   int inventorySize;
   int total;
public:
   cashRegister() {
       init();
   }


   void printInventory(int &choice, int &quantity) {
       cout << "Enter Item to purchase: ";
       for (int i = 0; i < inventorySize; i++) {
           cout << i+1 << "t" << items[i]-> getDescription() << " " << items[i]->getCost() << " " << items[i]->getUnits() << endl;
       }
       cin >> choice;
       cout << "enter quantity: " << endl;
       cin >> quantity;
   }

   void printCart(int choice, int quantity) {
       if (quantity > items[choice - 1]->getUnits())
           return;
       cout << "Item in cart: " << endl;
       double cost = items[choice]->getCost() * 1.3;
       cout << items[choice - 1]->getDescription() << " " << cost << " " << quantity << endl;
       total = cost * quantity;
       cout << "**************TOTAl = " << total;

       cout << "Total: " << total;
   }

   void init() {
       cout << "Enter number of items in inventory: ";
       cin >> inventorySize;
       items = new InventoryItem*[inventorySize];
       for (int i = 0; i < inventorySize; i++) {
           string desc;
           int price;
           int units;
           cout << "For item: "<< i + 1 << endl;
           cout << "Enter Item description: " << endl;
           getline(cin,desc);
           cout << "Enter item cost price: " << endl;
           cin >> price;
           cout << "Enter item units available : " << endl;
           cin >> units;
           items[i] = new   InventoryItem(desc, price, units);
       }
   }
};


int main() {
   cashRegister cr;
   int choice, quantity;
   cr.printInventory(choice, quantity);
   cr.printCart(choice, quantity);
}