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 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
|
#include <iostream>
#include <cstdlib>
#include <string>
#include <fstream>
#include <windows.h>
using namespace std;
void addInventory()
{
system("cls");
char filename[20];
string Item1, Item2, Item3, Item4, Item5, choice5;
unsigned int choice, choice2, choice3, choice4, s,s1, s2, s3, s4, answer,answer1,answer2, answer3,answer4, answer5;
cout << "\nAdd Item 1 ";
cin >> Item1;
cout << "Add Item 2 ";
cin >> Item2;
cout << "Add Item 3 ";
cin >> Item3;
cout << "Add Item 4 ";
cin >> Item4;
cout << "Add Item 5 ";
cin >> Item5;
cout << "\n\nItem Quantity\n\n"; // choosing quantities for items named above
cout << Item1 << ": ";
cin >> s;
cout << Item2 << ": ";
cin >> s1;
cout << Item3 << ": ";
cin >> s2;
cout << Item4 << ": ";
cin >> s3;
cout << Item5 << ": ";
cin >> s4;
system("cls");
cout << "\nUpdating Darkroom Inventory.... \n";// printing out items and quantities
cout << Item1 << ": " << s << endl;
cout << Item2 << ": " << s1 << endl;
cout << Item3 << ": " << s2 << endl;
cout << Item4 << ": " << s3 << endl;
cout << Item5 << ": " << s4 << endl;
system("cls");
cout << "\nEnter the name of the file you want your data to be saved in." << endl;
cin >> filename;
ofstream Inventory(filename, ios::out);
Inventory << Item1 << ": " << s << "\n";
Inventory << Item2 << ": " << s1 << "\n";
Inventory << Item3 << ": " << s2 << "\n";
Inventory << Item4 << ": " << s3 << "\n";
Inventory << Item5 << ": " << s4 << endl;
}
void checkInventory()
{
void editInventory()
{
string Item1, Item2, Item3, Item4, Item5, choice5;
unsigned int choice, choice2, choice3, choice4, choices, s,s1, s2, s3, s4, answer,answer1,answer2, answer3,answer4, answer5;
system("cls");
cout << "Edit Inventory" << endl;
cout << "\n1. Add to inventory\n";
cout << "2. Subtract from inventory\n" << endl;
cin >> choices;
if (choices == 1){
cout << "\nHow much do you want to add to Item 1 " << Item1 << endl;
cin >> answer;
cout << Item1 << s + answer << endl;
cout << "How much do you want to add to Item 2 " << Item2 << endl;
cin >> answer2;
cout << s1 + answer2 << endl;
cout << "How much do you want to add to Item 3 " << Item3 << endl;
cin >> answer3;
cout << s2 + answer3 << endl;
cout << "How much do you want to add to Item 4 " << Item4 << endl;
cin >> answer4;
cout << s3 + answer4 << endl;
cout << "How much do you want to add to Item 5 " << Item5 << endl;
cin >> answer5;
cout << s4 + answer5 << endl;
ofstream Inventory("inventory.txt", ios::in);
Inventory << Item1 << ": " << s - answer << endl;
Inventory << Item2 << ": " << s1 - answer2 << endl;
Inventory << Item3 << ": " << s2 - answer3 << endl;
Inventory << Item4 << ": " << s3 - answer4 << endl;
Inventory << Item5 << ": " << s4 - answer5 << endl;
}else {
cout << "\nHow much do you want to subtract to Item 1 " << Item1 << endl;
cin >> answer;
cout << s - answer << endl;
cout << "How much do you want to subtract to Item 2 " << Item2 << endl;
cin >> answer2;
cout << s1 - answer2 << endl;
cout << "How much do you want to subtract to Item 3 " << Item3 << endl;
cin >> answer3;
cout << s2 - answer3 << endl;
cout << "How much do you want to subtract to Item 4 " << Item4 << endl;
cin >> answer4;
cout << s3 - answer4 << endl;
cout << "How much do you want to subtract to Item 5 " << Item5 << endl;
cin >> answer5;
cout << s4 - answer5 << endl;
ofstream Inventory("inventory.txt", ios::in);
Inventory << Item1 << ": " << s - answer << endl;
Inventory << Item2 << ": " << s1 - answer2 << endl;
Inventory << Item3 << ": " << s2 - answer3 << endl;
Inventory << Item4 << ": " << s3 - answer4 << endl;
Inventory << Item5 << ": " << s4 - answer5 << endl;
}
}
int main()
{
int choice, choice2;
do {
system("cls");
cout << "Darkroom Inventory Version 1.\n\n";
cout << "1. Add Inventory\n";
cout << "2. Check Inventory\n";
cout << "3. Edit Inventory\n";
cin >> choice;
switch ( choice ) {
case 1: addInventory(); break;
case 2: checkInventory();break;
case 3: editInventory(); break;
}
|