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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include<fstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
const int invSize = 2;
//Function Prototypes//
void getInventory(ifstream& infile, vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice);
void displayMenu(vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice);
void sellItem(vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice);
void itemSearch(vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice);
void printReport(vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice);
int main()
{
//Function Main//
//Variables//
vector<int> itemQuantity;
vector<string> itemID;
vector<string> itemName;
vector<int> pOrdered;
vector<int> pInStore;
vector<int> pSold;
vector<double> manufPrice;
vector<double> sellingPrice;
ifstream infile;
//Inventory Text file created by, //
infile.open("c:\\inventory.txt");
//Display error if file is not open//
if (!infile)
{
cout << "Error in opening inventory file " << endl;
return 1;
}
getInventory(infile, itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice);
displayMenu(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice);
infile.close();
return 0;
}
//getInventory function//
void getInventory(ifstream& infile, vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice)
{
unsigned int i;
string line;
for (i = 0; i < itemID.size(); i++)
{
infile >> itemID[i]
>> itemName[i]
>> pOrdered[i]
>> manufPrice[i]
>> sellingPrice[i];
pInStore[i] = pOrdered[i];
pSold[0] = 0;
}
}
void displayMenu(vector<string> itemID, vector<string> itemName, vector<int> pOrdered, vector<int> pInStore, vector<int> pSold, vector<double> manufPrice, vector<double> sellingPrice)
{
char menuAnswer;
cout << "Type 'C' to check if an item is in stock." << endl;
cout << "Type 'S' to sell an item to a customer." << endl;
cout << "Type 'R' to print an inventory report." << endl;
cin >> menuAnswer;
if (menuAnswer == 'C' || menuAnswer == 'c')
itemSearch(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice);
if (menuAnswer == 'S' || menuAnswer == 's')
sellItem(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice);
if (menuAnswer == 'R' || menuAnswer == 'r')
printReport(itemID, itemName, pOrdered, pInStore, pSold, manufPrice, sellingPrice);
}
|