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

Cash Register Design a cashRegister class that can be used with the inventory cl

ID: 3620543 • Letter: C

Question

Cash Register
Design a cashRegister class that can be used with the inventory class assigneded earlier .

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 subtotal.
5. 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 above
in any way necessary.
Input Validation: Do not accept a negative value for the quantity of items been
purchased

Explanation / Answer

Dear, #ifndef TAX_H #define TAX_H //Tax class declaration class Tax { private: double itemCost; //cost of the item double taxRate; //sales tax rate public: //pull user input to get itemCost with tax rate 6% Tax(double subTotal, double rate = 0.06) { itemCost = subTotal; taxRate = rate; } //get Item cost return double getItemCost() const { return itemCost; } //get tax rate double getTaxRate() const { return taxRate; } //get tax times itemCost double getTax() const { return (itemCost * taxRate); } //get subtotal double getTotal() const { return (itemCost + getTax()); } };#endif #ifndef INVENTORYITEM_H #define INVENTORYITEM_H #include //needed for strlen and strcpy //constant for description's default sizeconst int DEFAULT_SIZE = 51; //InventoryItem class declaration class InventoryItem {private: char *description; //item description double cost; //item cost double units; //Number of units on hand // Private member function.void InventoryItem::createDescription(int size, char *value) { // Allocate the default amount of memory for description. description = new char [size+1]; // Store a value in the memory. strcpy(description, value); } public: //constructor #1 InventoryItem() { //store an empty string in the description attribute. createDescription(DEFAULT_SIZE, ""); //initialize cost and units. cost = 0.0; units = 0; } //constrcutor #2 InventoryItem(char *desc) { //allocate memory and store the description. createDescription(strlen(desc), desc); //initialize cost and units. cost = 0.0; units = 0; } //constructor #3 InventoryItem(char *desc, double c, double u) {//allocate memory and store the description. createDescription(strlen(desc), desc); //assign values to cost and units. cost = c; units = u; } //Destructor ~InventoryItem() { delete [] description; } //Mutator functions void setDescription(char *d) { strcpy(description, d); } void setCost(double c) { cost = c; } void setUnits(double u) { units = u; } //Accessor functions const char *getDescription() const { return description; } double getCost() const { return cost; } double getUnits(double qtySelected) { units -= qtySelected; return units; } };#endif //This program demonstrates a class with a destructor #include #include #include "Profit.h" #include "Tax.h" #include "InventoryItem.h" using namespace std; int main() { int numSelected; //to hold number selected double qtySelected; //to hold number of items ordered char again; //to hold yes or no answer double profitPrice; //to hold unit price amount for profit class double subTotal; //to hold sub total price for tax class const int NUM_ITEMS = 5; //array of inventory items InventoryItem inventory[] = { InventoryItem("Hammer", 6.95, 12), InventoryItem("Wrench", 8.75, 20), InventoryItem("Pliers", 3.75, 10), InventoryItem("Ratchet", 7.95, 14), InventoryItem("Screwdriver", 2.50, 22) }; //do loop for program to function do{ //set numeric output formatting cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote