123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
#include<iostream> #include<string> #include<cctype> #include<cstdlib> #include <iomanip> #include <windows.h> #include<conio.h> #include<ctype.h> using namespace std; ////////////use this structure name in creating the members of inventory////////////// struct Products { //add code here; string productType; int prodQuantity; string prodName[]; double prodPrice[]; int prodStock[]; int prodSold[]; }; //////////////////////////////code for getting the password////////////////////////////////// string EnterPassword() { string NumAsString=""; char ch=getch();//h while (ch!='\r') {//true cout<<'*';//***** NumAsString+=ch;//"hello" ch=getch();//enter/return } return NumAsString; } /////////////////////prototypes of functions//////////////////////////////////////////////// void password(); int ENTERPROD(); void INPUTPROD(int val); //////////////////////////////////////////////////////////////////// int main() // DO NOT ADD or REVISE ANYTHING FROM THIS FUNCTION { int count; password(); cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); system("cls"); cout<<" ***** INVENTORY SYSTEM CS127L 4TH QTR*****"<<endl<<endl; count=ENTERPROD(); cout<<endl<<"ENTER "<<count<<" PRODUCTS"<<endl; INPUTPROD(count); cout<<endl; system("pause"); } //////////////////////////////////// int ENTERPROD() { //add code here int prodNum; cout<<"ENTER NUMBER OF PRODUCTS FOR INVENTORY: "; cin>>prodNum; cin.ignore(); return prodNum; } ///////////////////////////////////// void INPUTPROD(int val) { Products prodArray[val]; int i,prodIndex,quantity; for(i=0;i<val;i++) { cout<<"Product"<<i+1<<":"; getline(cin,prodArray[i].productType); cout<<"How many "<<prodArray[i].productType<<" ?"; cin>>quantity; cin.ignore(); for(prodIndex=0;prodIndex<quantity;prodIndex++) { cout<<prodArray[i].productType<<"["<<prodIndex+1<<"]: \n"; getline(cin,prodArray[i].prodName[prodIndex]); cout<<"Price: \n"; cin>>prodArray[i].prodPrice[prodIndex]; cin.ignore(); cout<<"Stock: \n"; cin>>prodArray[i].prodStock[prodIndex]; cin.ignore(); cout<<"Sold: \n"; cin>>prodArray[i].prodSold[prodIndex]; cin.ignore(); } } } ////////////////////////////////////////////////////////////////////////////////// void password() { //add code here //call function EnterPassword HEREā¦ string userId,userPassword,pW,secretPw; userPassword="jaymark"; secretPw="12345"; int tryUser=3; int tryPw=3; cout<<"PRODUCT INVENTORY SYSTEM CS127L"; bool again=true; while(again) { cout<<"\nYou have "<<tryUser<<" tries remaining"; cout<<"\nUsername: "; getline(cin,userId); try { if (userPassword.compare(userId)!=0) { throw userId; break; } again=false; } catch(string x) { tryUser--; if (tryUser==0) { cout<<"Maximum tries reached! Terminating!"; exit(1); } else { cout<<"Invalid Username!"<<"\nTry Again!\n"; continue; } } } cout<<"Welcome! "<<userId<<endl; Sleep(1000); system("cls"); bool passAgain=true; while(passAgain) { cout<<"\nYou have "<<tryPw<<" tries remaining"; cout<<"\nPassword: "; pW=EnterPassword(); try { if (secretPw.compare(pW)!=0) { throw userId; break; } passAgain=false; } catch(string y) { tryPw--; if (tryPw==0) { cout<<"Maximum tries reached! Terminating!"; exit(1); } else { cout<<"\n\nWrong Password!"<<"\nTry Again!"; continue; } } } }