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 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209
|
#include <iostream>
#include <string>
#include <fstream>
#include <locale>
using namespace std;
int main();
void newmaterial();
void searchmaterial();
int main()
{
int a;
cout << "Homepage" << endl << endl;
cout << "Enter 1 to input a new material" << endl;
cout << "Enter 2 to search for a material" <<endl;
cin >> a;
cout << endl;
if (a==1){
newmaterial();
}
if (a==2){
searchmaterial();
}
return 0;
}
void newmaterial()
{
ofstream warehouse;
string name;
string location;
string type;
string description;
string quantity;
int x;
warehouse.open("material.txt", ios::app);
cout << "Enter a New Material" << endl << endl;
cout << "What is the material name? ";
cin >> name;
cout << "What is the location of the material? ";
cin >> location;
cout << "What is the type of the material? ";
cin >> type;
cout << "What is the description of the material? ";
getline(cin, description);
cout << "What is the quantity of the material? ";
cin >> quantity;
warehouse << name << location << type << description << quantity << endl;
warehouse.close();
cout << endl;
cout << "Enter 1 to return to homepage" << endl;
cout << "Enter 2 to enter a new material" << endl;
cout << "Enter 3 to exit" << endl;
cin >> x;
cout << endl;
if (x==1){
main();
}
if (x==2){
newmaterial();
}
if (x==3){
return ;
}
}
void searchmaterial()
{
ifstream warehouse;
string name;
string location;
string type;
string description;
string quantity;
int b, c, i;
string l;
string j;
locale a;
cout << "Search for a material" << endl << endl;
cout << "Enter 1 to search by material name" << endl;
cout << "Enter 2 to search by location" << endl;
cin >> b;
cout << endl;
warehouse.open("material.txt", ios::in);
if (b==1){
cout << "Input material to look for: ";
cin >> j;
for (i=0; i<10; i++){
while (warehouse >> name >> location >> type >> description >> quantity){
if (toupper(j[i],a)==toupper(name[i], a)){
cout << "Material name: " << toupper(name[i],a) << endl;
cout << "Location: " << toupper(location[i],a) << endl;
cout << "Type: " << toupper(type[i],a) << endl;
cout << "Description: " << description << endl;
cout << "Quantity: " << quantity << endl;
} else {
cout << "Not found!" << endl;
}
}
}
}
if (b==2){
cout << "Input location: ";
cin>> l;
for (i=0; i<10; i++){
while (warehouse >> name >> location >> type >> description >> quantity){
if (toupper(l[i],a)==toupper(location[i],a)){
cout << "Material name: " << toupper(name[i],a) << endl;
cout << "Location: " << toupper(location[i],a) << endl;
cout << "Type: " << type << endl;
cout << "Description: " << description << endl;
cout << "Quantity: " << quantity << endl;
} else{
cout << "Not found!" << endl;
}
}
}
}
warehouse.close();
cout << endl;
cout << "Enter 1 to return to homepage" << endl;
cout << "Enter 2 to search for another material" << endl;
cout << "Enter 3 to exit" << endl;
cin >> c;
cout << endl;
if (c==1){
main();
}
if (c==2){
searchmaterial();
}
if (c==3){
return ;
}
}
|