0% found this document useful (0 votes)
4 views10 pages

SAMPLEEE

This document contains code for a C++ program that implements a furniture shop management system with user and admin accounts. It includes functions for user login/registration, viewing items and account balances, buying items, and admin functions like managing items and accounts. Arrays are used to store username/password, item, and account balance data. The functions implement a menu-driven interface for users to interact with items and accounts, and admins to manage the shop's inventory and customer accounts.

Uploaded by

Mariel Villete
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views10 pages

SAMPLEEE

This document contains code for a C++ program that implements a furniture shop management system with user and admin accounts. It includes functions for user login/registration, viewing items and account balances, buying items, and admin functions like managing items and accounts. Arrays are used to store username/password, item, and account balance data. The functions implement a menu-driven interface for users to interact with items and accounts, and admins to manage the shop's inventory and customer accounts.

Uploaded by

Mariel Villete
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 10

#include <conio.

h>
#include <iostream.h>
#include <stdlib.h>
#include <string.h>

//edited2

//DECLARE FUNCTIONS
void login();//choose user or admin account
void admin_f();//admin login
void user_f();//choose user login or register account
void user_log();//user login
void user_reg();//register user account
void main_menu();//user main menu
void item_menu();//view items or buy items
void view_item();//user view items
void account_balance();//user's account balance
void change();//user change username or password
void buy_items();//user buy items
void admin_menu();//admin main menu
void manage_items();//view items and add items
void manage_acct();//view accounts

//DECLARE ARRAYS
char admin[10] = "admin";
char adminpass[10] = "1234";
char username[30][20] = {"teo", "harry", "jay", "joseph", "angel"};
char password[30][20] = {"meat", "carrot", "work", "muse", "1004"};
int money[10] = {10000, 20000, 10000, 25000, 15000};
char items[30][30] = {"Racking Chair", "Dinning Table", "Display Cabinet", "Coffee
Table", "Flower Vase "};
int price[20] = {7500, 8000, 7700, 5000, 2300};

//VARIABLES
int opt = 0, count=5, num=5, acct=0;

void main()
{
clrscr();
login();
getch();

//FUNCTIONS

void login()
{
clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"Log-in | Register"<<endl;
cout<<""<<endl;
cout<<"[1] User"<<endl;
cout<<"[2] Admin"<<endl;
cout<<"[3] Exit"<<endl;
cout<<""<<endl;
cout<<"Enter: ";
cin>>opt;

if (opt==1)
{ clrscr();
user_f();
getch();
}

else if (opt==2)
{ clrscr();
admin_f();
getch();
}

else if (opt==3)
{ exit(0);
getch();
}

else { clrscr();
main();
getch();
}
getch();

void user_f()
{
clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"USER"<<endl;
cout<<""<<endl;
cout<<"[1] Log-in"<<endl;
cout<<"[2] Register"<<endl;
cout<<"[3] Back"<<endl;
cout<<""<<endl;
cout<<"Enter: "<<endl;
cin>>opt;

switch (opt)
{ case 1: user_log();
break;

case 2: user_reg();
break;

case 3: login();
break;
}

getch();

void admin_f()

char admin_u[10], apass[10];

clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"Admin"<<endl;
cout<<""<<endl;
cout<<"Username: ";
cin>>admin_u;
cout<<"Password: ";
cin>>apass;
cout<<""<<endl;

if(strcmp(admin,admin_u)==0, strcmp(adminpass, apass)==0)


{ admin_menu(); }

else {
cout<<"Incorrect Username/Password";
getch();
login();
}

getch();

void user_log()
{

char user_name[10], user_pass[10];

clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"User Log-in"<<endl;
cout<<""<<endl;
cout<<"Username: ";
cin>>user_name;
cout<<"Password: ";
cin>>user_pass;
cout<<""<<endl;
for (int x=0; x<count; x++)
{
if(strcmp(user_name, username[x])==0)
{
if(strcmp(user_pass, password[x])==0)
{
cout<<"welcome: "<<username[x];
acct=x;
main_menu();
}
else cout<<"wrong password";
}
//else cout<<"wrong user";

}
getch();

login();
}

void user_reg()
{

clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"Register Account"<<endl;
cout<<""<<endl;
cout<<"Username: ";
cin>>username[count];

for(int x=0; x<count; x++)


{ if(strcmp(username[x], username[count])==0)
{ cout<<"This username is already exist!!!";
getch();
user_reg();
}
}

cout<<"Password: ";
cin>>password[count];
cout<<"Account Balance: ";
cin>>money[count];

cout<<""<<endl;
cout<<"Registration Complete!"<<endl;

count++;

getch();

user_log();

void main_menu()
{

clrscr();
cout<<"WELCOME TO FURNITURE SHOP"<<endl;
cout<<""<<endl;
cout<<"MAIN MENU"<<endl;
cout<<""<<endl;
cout<<"[1] View Items"<<endl;
cout<<"[2] Account Balance"<<endl;
cout<<"[3] Change Username/Password"<<endl;
cout<<"[4] Log-out"<<endl;
cout<<""<<endl;
cout<<"Enter: "<<endl;
cin>>opt;

switch(opt)
{ case 1: item_menu();
break;

case 2: account_balance();
break;

case 3: change();
break;

case 4: login();
break;
}

getch();

void item_menu()
{

clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"ITEM MENU"<<endl;
cout<<""<<endl;
cout<<"[1] Buy Items"<<endl;
cout<<"[2] Back"<<endl;
cout<<"Enter: "<<endl;
cin>>opt;

switch(opt)
{ case 1: buy_items();
break;

case 2: main_menu();
break;

getch();
}

void buy_items()
{

int qty=0, item_price=0, item_num=0;


clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"BUY ITEMS"<<endl;
cout<<""<<endl;

cout<<"ITEMS\t\t\t\tPRICE"<<endl;
for (int x=0; x<num; x++) {
cout<<"["<<x<<"] "<<items[x]<<"\t\t"<<price[x]<<endl;
}

cout<<""<<endl;
cout<<"Input Item No.: ";
cin>>item_num;
cout<<"Input Quantity: ";
cin>>qty;

item_price = qty*price[item_num];

if (money[acct] <= item_price){


cout<<"You have insuficient money";
getch();
buy_items();
}

cout<<""<<endl;
cout<<"Total Price: "<<item_price<<endl;;
cout<<"YOU CHECKED OUT SUCCESSFULLY!!!"<<endl;

money[acct]-=item_price;

cout<<""<<endl;
cout<<"REMAINING BALANCE DISPLAY"<<endl;
cout<<money[acct];

cout<<""<<endl;
cout<<"[press enter to exit]"<<endl;

getch();

main_menu();
}

void account_balance()
{
clrscr();
cout<<"WELCOME TO FURNITURE SHOP"<<endl;
cout<<""<<endl;
cout<<"ACCOUNT BALANCE DISPLAY"<<endl;

cout<<""<<endl;
cout<<username[acct]<<"'s current balance: "<<money[acct]<<endl;
cout<<""<<endl;
cout<<"[press enter to exit]"<<endl;

getch();

main_menu();

void change()
{
char change_user[30], change_pass[30];

clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"CHANGE USERNAME | PASSWORD"<<endl;
cout<<""<<endl;
cout<<"[1] Change Username"<<endl;
cout<<"[2] Change Password"<<endl;
cout<<"[3] Back"<<endl;
cout<<"Enter: "<<endl;
cin>>opt;

switch(opt)
{ case 1: cout<<"WELCOME TO FURNITURE SHOP"<<endl;
cout<<""<<endl;
cout<<"CHANGE USERNAME"<<endl;
cout<<""<<endl;
for(int x=0; x<count; x++){
cout<<"Type new username: ";
cin>>username[x];
cout<<"Username successfully change!"<<endl;
cout<<"[press enter to exit]"<<endl;
getch();
change();
}
break;

case 2: cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"CHANGE PASSWORD"<<endl;
cout<<""<<endl;
for(int i=0; i<count; i++){
cout<<"Type new password: ";
cin>>password[x];
cout<<"Password successfully change!"<<endl;
cout<<"[press enter to exit]"<<endl;
getch();
change();
}
break;
case 3: main_menu();
break;

getch();

void admin_menu(){
clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"MAIN MENU"<<endl;
cout<<""<<endl;
cout<<"[1] Manage Items"<<endl;
cout<<"[2] Manage Accounts"<<endl;
cout<<"[3] Change Password"<<endl;
cout<<"[4] Log-out"<<endl;
cout<<""<<endl;
cout<<"Enter: ";
cin>>opt;

switch(opt)
{ case 1: manage_items();
break;

case 2: manage_acct();
break;

case 3: clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"CHANGE PASSWORD"<<endl;
cout<<""<<endl;
cout<<"Type new password: ";
cin>>adminpass;
cout<<""<<endl;
cout<<"Password change successfully!"<<endl;
cout<<""<<endl;
cout<<"[press enter to exit]"<<endl;

getch();
admin_menu();

break;

case 4: login();
break;

getch();
}

void manage_items(){
clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"MANAGE ITEMS"<<endl;
cout<<""<<endl;
cout<<"[1] View Items"<<endl;
cout<<"[2] Add Items"<<endl;
cout<<"[3] Back"<<endl;
cout<<""<<endl;
cout<<"Enter: ";
cin>>opt;

switch(opt)
{ case 1: clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"VIEW ITEMS"<<endl;
cout<<""<<endl;
cout<<"ITEMS \t\t\t\t PRICE"<<endl;
for (int x=0; x<num; x++){
cout<<"["<<x<<"] "<<items[x]<<"\t\t"<<price[x]<<endl;
}
cout<<""<<endl;
cout<<"[press enter to exit]"<<endl;
getch();
manage_items();
break;

case 2: clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"ADD ITEMS"<<endl;
cout<<""<<endl;
cout<<"Item name: "<<endl;
cin>>items[num];
cout<<"Item price: "<<endl;
cin>>price[num];

cout<<"Item successfully added!"<<endl;


num++;

getch();
manage_items();
break;

case 3: admin_menu();
break;
}

getch();

}
void manage_acct(){
clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"MANAGE ACCOUNTS"<<endl;
cout<<""<<endl;
cout<<"[1] View Accounts"<<endl;
cout<<"[2] Back"<<endl;
cout<<""<<endl;
cout<<"Enter: ";
cin>>opt;

switch(opt)
{ case 1: clrscr();

cout<<"WELCOME TO FURNITURE SHOP"<<endl;


cout<<""<<endl;
cout<<"VIEW ACCOUNTS"<<endl;
cout<<""<<endl;
cout<<"ACCOUNTS \t\t BALANCE"<<endl;
for (int x=0; x<num; x++){
cout<<"["<<x<<"] "<<username[x]<<"\t\t"<<money[x]<<endl;
}
cout<<""<<endl;
cout<<"[press enter to exit]"<<endl;
getch();
manage_acct();
break;

case 2: admin_menu();
break;
}
getch();

You might also like