Question: // when you compile and run the program and you get the black screen press No1(manager menu, password is devices) then again press No1(add stock)

// when you compile and run the program and you get the black screen press No1(manager menu, password is devices) then again press No1(add stock) when you get there and you put the devices, quantity and price. Can you please make sure the information you put there or I put write in the table it will take you.

//thanks in advance.

//this is the code

#include #include #include #include #include using namespace std;

struct devicedata { string device_name; float quantity; char price; int stock; string pname; };

int stock, price; string pname;

void add(); // add devices void show(); // show devices int remove(); // remove devices void purchase(); // purchase void available(); //available devices

int main() {

int c; char pass[0]; mainmenu: // welcoming window and you have choices to choose cout<< "\t\t\t\t============================================================== "; cout<< "\t\t\t\t| WELCOME TO ELECTRICAL AND ELECTRONIC DEVICES STOCK MANAGER | "; cout<< "\t\t\t\t=============================================================="; cout<< " \t\t\t\t============================================================== \t\t\t\t[1.] Manager Menu \t\t\t\t[2.] Customer Menu \t\t\t\t[3.] Exit \t\t\t\t============================================================== "; cout<< "press number"; cin>>c;

switch(c) { case 1: { A: cout<<"Enter your password : "; cin>>pass; if(strcmp(pass,"devices")==0) { system("cls"); goto managermenu; } else { cout<<" Invalid password... "; goto A; }

} case 2: { system("cls"); goto customermenu; } case 3: { exit(0); } } int a, b; managermenu: // this is specifically for manager and it has a password cout<<"\t\t\t\t\t ========================== "; cout<<"\t\t\t\t\t| WELCOME TO MANAGER MENU | "; cout<<"\t\t\t\t\t =========================="; cout<<" \t\t\t\t============================================ \t\t\t\t[1.] Add Stock \t\t\t\t[2.] Available Stock \t\t\t\t[3.] Remove Stock \t\t\t\t[4.] Go Back \t\t\t\t[5.] Exit \t\t\t\t============================================ "; cout<< "press number"; cin>>a;

switch(a) { case 1: { add(); system("cls"); show(); getch(); system("cls"); goto managermenu; break; } case 2: { system("cls"); show(); getch(); goto managermenu; break; } case 3: { remove(); getch(); goto managermenu; break; } case 4: { system("cls"); goto mainmenu; } case 5: { exit(0); }

} customermenu: // this one is for the customers, you can purchase or see available devices cout<<"\t\t\t\t\t============================ "; cout<<"\t\t\t\t\t| WELCOME TO CUSTOMER MENU | "; cout<<"\t\t\t\t\t============================"; int d; cout<<" \t\t\t\t================================================ \t\t\t\t[1.] Purchase \t\t\t\t[2.] Available stock \t\t\t\t[3.] Back to mainmenu \t\t\t\t[4.] Exit \t\t\t\t================================================ "; cout<< "press number"; cin>>d; switch(d) { case 1: { purchase(); goto customermenu; break;

} case 2: { system("cls"); show(); getch(); system("cls"); goto customermenu; break; } case 3: { system("cls"); goto mainmenu; } case 4: { exit(0); } }

getch(); return 0;

}

void add() { // this is when you wanna add product or device for(int i = 0; i < 2; i++) { cout<<"Enter device name, price and quantity respectively "<< i+1 << ":"; cin>>pname>>price>>stock; ofstream shop; shop.open("shop.txt" , ios::app); shop<

void show() { // this is to show availabel stock cout<<" \t\t\t======================================================================"; cout<<" \t\t\t=================\t AVAILABLE STOCKS:\t======================"; cout<<" \t\t\t====================================================================== "; cout<<" \t\t\t\t\t DEVICES\t QUANTITY AVAILABLE\t PRICE(RM)"; cout<<" \t\t\t====================================================================== ";

// this is to calculate total expense and if the totalexpense is more than the designed price then there will be discount int totalexp, qty, price, discount;

cout<<"\t\t\t\t\tEnter total quantity:"; cin>>qty; cout<<"Enter total price:"; cin>>price;

totalexp=qty*price;

if(totalexp>2000) { discount=(totalexp*0.2); totalexp=totalexp-discount; }

cout<<"Total Expense is RM. "<

ifstream show; show.open("shop.txt"); show>>pname; show>>stock; show>>price; if(!show.eof() ) { cout<<"\t\t\t\t"<>pname; show>>stock; show>>price; } show.close(); }

int remove() { // incase manager wanna remove stock or device string b; cout<<"Enter the name of device you want to delete : "; cin>>b;

ifstream del; del.open("Devices.txt"); ofstream nfile; nfile.open("Devices.txt");

del>>pname; del>>stock; del>>price;

if(b!=pname) { cout<<" Product not found..."; }

while(!del.eof()) { if(pname !=b) { nfile<

else

cout<<"Record Deleted.";

del>>pname; del>>stock; del>>price; }

nfile.close(); del.close();

remove("shop.txt"); rename("temp.txt", "shop.txt");

}

void purchase() { // if you wanna purchase a device string p; int quantity; cout<<"Enter the name of device : "; cin>>p; cout<<"Enter quantity : "; cin>>quantity; ifstream buy; buy.open("Devices.txt", ios::app); ifstream tmp; tmp.open("temp.txt");

cout <

}

void available() { //these are the available devices and they are just a sample! for(int i = 0; i < 10; i++) { int electrical, electronic, devices[5][5]; cout<<"\t\t\t\t\t ========================================= "; cout<<"\t\t\t\t\t No Device price(RM) "; cout<<"\t\t\t\t\t ==========================================="; cout<<"\t\t\t\t\t Electrical Devices" ; cout<<"\t\t\t\t\t 1 Fuse 8 "; cout<<"\t\t\t\t\t 2 Switch 13 "; cout<<"\t\t\t\t\t 3 Light bulb 10 "; cout<<"\t\t\t\t\t 4 Battery 20 "; cout<<"\t\t\t\t\t 5 Toaster 50 "; cout<<"\t\t\t\t\t Electronic Devices" ; cout<<"\t\t\t\t\t 6 Laptop 2000 "; cout<<"\t\t\t\t\t 7 Desktop Computer 2900 "; cout<<"\t\t\t\t\t 8 Mobile Phone 2000 "; cout<<"\t\t\t\t\t 9 Ipod 1500 "; cout<<"\t\t\t\t\t 10 Camera 1000 "; cin>>electrical; cin>>electronic; cin.ignore(); } cout<

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!