c++ Cash Register. This program will use two classes; one of the classes is prov
ID: 671373 • Letter: C
Question
c++
Cash Register. This program will use two classes; one of the classes is provided in the assignment description for week 7 in the course site. Write a class name CashRegister, with the class declaration in a file called CashRegister.h and the implementation in a file called CashRegister.cpp. This class will interact with the InventoryItem class that has been provided. The program should display a list of items that are available to purchase.
InventoryItem.cpp holds the following code:
InventoryItem.h holds the following code:
The program will ask the user for the item and quantity being purchased. It will then get the cost of the item from the InventoryItem object. It will add 30% profit to the cost of the item to get the item’s unit price. It will then multiply the unit price times the quantity being purchased to get the purchase subtotal. The program will then compute a 6% sales tax on the subtotal to get the purchase total. It should then display the purchase subtotal, tax and total on the screen. The program will then subtract the quantity being purchased from the onHand variable of the InventoryItem class object. InventoryItem will need to be modified to handle this.
Validation: Do not accept a negative value for the quantity of items being purchased.
C:Windows system321cmd.exe Item qty on Hand Adjustable Wrench 10 Screwdriver Pliers Ratchet Socket Wrench 20 35 10 7 4 5 Which item above is being purchased?Explanation / Answer
/* CIST 2362 - 20786 - Kimberly Jackson - SID: 0332 Week 2, Cash Register class program - 9/4/12 Description: Create a CashRegister class that asks the user for the item they are purchasing and the quantity. It should then collect the cost of a single item and mark it up 30% to determine the individual retail cost of that item. This is of course followed by multiplying the retail cost by the number of items being purchased. This is the subtotal. Multiply that subtotal by the 6% sales tax and display that, then display the total (subtotal+(subtotal*.06)). Then subtract the number of items being purchased from the stock. Input validation: Do not accept negative numbers for the quantity. Error checking: Verify that there are enough items to sell. */ #include "InventoryItem.h" #include "CashRegister.h" #include using namespace std; //global constants //default constructor CashRegister::CashRegister() { quantity=0; retailCost=0.0; subtotal=0.0; total=0.0; }; //mutators //accepts user input to set quantity void CashRegister::setQuantity(int q) { quantity=q; }; //accepts inventoryitem cost and user input quantity to set the subtotal void CashRegister::setsubtotal(double rcost, int q) { subtotal = subtotal + (rcost*q); }; void CashRegister::setCost(double rcost, double PROFIT_MARGIN) { retailCost = rcost + (rcost*PROFIT_MARGIN); }; void CashRegister::resetCostquant() { retailCost = 0.0; quantity = 0; }; void CashRegister::setTotal(double subT, double SALES_TAX) { total =((subT*SALES_TAX)+subT); }; //accessors int CashRegister::getQuantity() const { return quantity; }; double CashRegister::getsubtotal() const { return subtotal; }; double CashRegister::getCost() const { return retailCost; }; double CashRegister::getTotal() const { return total; };Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.