1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
#include "Cash Register Header.h"
#include "Inventory Item Header.h"
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int pickItem, pickUnits;
double newcost = 0;
InventoryItem Item, SetItemCost, SetU, GetU, NewItem();
CashRegister subobj, totobj, taxobj;
const int NUM_ITEMS = 5;
InventoryItem inventory[NUM_ITEMS] = {
InventoryItem("Hammer", 6.95, 12, 10),
InventoryItem("Wrench", 8.75, 20, 10),
InventoryItem("Pliers", 3.75, 10, 10),
InventoryItem("Ratchet", 7.95, 14, 10),
InventoryItem("Screwdriver", 2.50, 22, 10) };
cout << setw(14) <<"Inventory Item"
<< setw(8) << "Cost" << setw(8)
<< setw(16) << "Units on Hand\n";
cout << "-------------------------------------\n";
for (int i = 0; i < NUM_ITEMS; i++)
{
cout << setw(14) << inventory[i].getDescription();
cout << setw(8) << inventory[i].getCost();
cout << setw(7) << inventory[i].getUnits() << endl;
}
cout << "\n";
cout << "Enter #1 to #5 for item selection " << endl;
cin >> pickItem; cout << "\n";
cout << "How many? " << endl;
cin >> pickUnits; cout << "\n";
switch (pickItem)
{
case 1: newcost = inventory[0].getCost() * pickUnits; break;
case 2: newcost = inventory[1].getCost() * pickUnits; break;
case 3: newcost = inventory[2].getCost() * pickUnits; break;
case 4: newcost = inventory[3].getCost() * pickUnits; break;
case 5: newcost = inventory[4].getCost() * pickUnits; break;
default: break;
}
cin.get();
cin.ignore();
return 0;
}
|