#include <iostream> #include <string> //#include <process> #include <fstream> void valid(); int choice,x,we; void Menu(); void Master_Entryfun(); void ComputerEntryfun(); void Member_Entryfun(); void cafe_managmentfun(); void booking(); using namespace std; int main() { while(getche() != '\r'); system("COLOR 09"); display(); for(int i = 0 ; i < 450000000 ; i++){} system("cls"); system("COLOR 0C"); displaypro(); for(int i = 0 ; i < 450000000 ; i++){} system("cls"); system("COLOR 0E"); displayroll(); for(int i = 0 ; i < 450000000 ; i++){} system("cls"); system("COLOR 0B"); displaywellcom(); while(getche() != '\r'); system("cls"); system("COLOR 70"); string username = "Huzaifa"; string pass = "364huz"; fflush(stdin); string iuser; char ipass[20]; for(int i = 0 ; i<3 ; i++) { system("cls"); cout << "\n\n\n\n\t\t\t ====== LOG IN ======"; cout << "\n\n\n\n\n"; cout << "\n \t\t \t Enter the User name : " ; getline(cin,iuser); cout << "\n\t\t\t Enter passward : "; { char a; for(int i = 0;;) { a = getch(); if((a >= 'a' && a <= 'z') || (a >= 'A' && a <= 'Z') || (a >= '0' && a <= '9')) { ipass[i] = a; i++; cout<<"*"; } if(a == '\b' && i >= 1) { cout<<"\b \b"; i--; } if(a == '\r') { ipass[i] = '\0'; break; } } } if(iuser == username && ipass == pass) { cout<<"\n\n\t\t Successfully loged in ! Press Enter to continue \n"; while(getche() != '\r'); Menu(); } cout<<"\n\n\t\t User name or passward incorrect ! Retry"; while(getche() != '\r'); } return 0; } void Menu() { system("cls"); cout << "\n\n\n\n\t\t\t "; cout << "\n\n"; cout<<"\t\t\t\t MENU \n"; cout<<"\t\t\t\t ________________________\n"; cout<<"\t\t\t\t| |"; cout << "\n\t \t\t \t| 1. Master Entry |"; cout << "\n \t\t\t \t| 2. Cafe Managment |"; cout << "\n \t\t\t \t| 3. Exit |\n"; cout<<"\t\t\t \t|________________________|\n"; cout << "\n\n"; valid(); switch(choice) { case 1: Master_Entryfun(); break; case 2: cafe_managmentfun(); break; case 3: exit(0); break; default: cout<<"Invalid choice ! Renter "; return Menu(); break; } } void Master_Entryfun() { Computer_Entry c; Member_Entry m; system("cls"); cout << "\n\n\n\n\t\t\t "; cout << "\n\n"; cout<<"\t\t\t\t MENU/MASTER ENTRY \n"; cout<<"\t\t\t\t ________________________\n"; cout<<"\t\t\t\t| |"; cout << "\n\t \t\t \t| 1. Member Entry |"; cout << "\n \t\t\t \t| 2. Computer Entry |"; cout << "\n \t\t\t \t| 3. Exit |\n"; cout<<"\t\t\t \t|________________________|\n"; cout << "\n\n"; valid(); switch(choice) { case 1: m.Member_Entryfun(); Master_Entryfun(); break; case 2: c.ComputerEntryfun(); Master_Entryfun(); break; case 3: return Menu(); break; default: cout<<"Invalid choice ! Renter "; return Master_Entryfun(); break; } } void cafe_managmentfun() { Member_Entry k; system("cls"); cout << "\n\n\n\n\t\t\t "; cout << "\n\n"; cout<<"\t\t\t\t MENU/CAFE MANAGMENT \n"; cout<<"\t\t\t\t ________________________\n"; cout<<"\t\t\t\t| |"; cout << "\n\t \t\t \t| 1. Booking |"; cout << "\n \t\t\t \t| 2. Charges |"; cout << "\n \t\t\t \t| 3. Renewal |"; cout << "\n \t\t\t \t| 4. Return |\n"; cout<<"\t\t\t \t|________________________|\n"; cout << "\n\n"; valid(); Charges c; switch(choice) { case 1: booking(); break; case 2: system("cls"); c.chargesfun(); return cafe_managmentfun(); break; case 3: system("cls"); k.renewalfun(); return cafe_managmentfun(); break; case 4: return Menu(); break; default: cout<<"Invalid choice ! Renter "; return cafe_managmentfun(); break; } } void booking() { system("cls"); cout << "\n\n\n\n\t\t\t "; cout << "\n\n"; cout<<"\t\t\t MENU/CAFE MANAGMENT/BOOKING \n"; cout<<"\t\t\t _______________________________________\n"; cout<<"\t\t\t| |"; cout << "\n\t \t \t| 1. Member log in |"; cout << "\n \t\t \t| 2. Member log out |"; cout << "\n \t\t \t| 3. Non Member User Log in |"; cout << "\n \t\t \t| 4. Logged in members |"; cout << "\n \t\t \t| 5. Which members used systems ?? |"; cout << "\n \t\t \t| 6. Return |\n"; cout<<"\t\t \t|_______________________________________|\n"; cout << "\n\n"; Member_login m; Computer_Entry c; valid(); switch(choice) { case 1: case1: system("cls"); if(c.searchComputerRecord()) { cout<<"\t\t\tComputer you want to use found!\n\t\t\t Enter user name and passward \n"; x = m.logintomemberid(); int i = x; if(x) { ifstream chk; chk.open("Using_comp.dat",ios::binary); if(chk.fail()) goto newcomp; chk.read(reinterpret_cast<char *>(&c),sizeof(c)); chk >> x ; while(!chk.eof()) { if(i == x) { cout<<"computer already in use "; return; } chk.read(reinterpret_cast<char *>(&c),sizeof(c)); chk >> x ; } chk.close(); newcomp: ofstream outcomp; outcomp.open("Using_comp.dat",ios::app|ios::binary); outcomp.write(reinterpret_cast<char *>(&c),sizeof(c)); outcomp << x ; outcomp.close(); } } else { cout<<"\nWanna Retry (y/n)? "; char ch; cin >>ch; if(ch == 'y' || ch == 'y') goto case1; else return booking(); } while(getche() != '\r'); return booking(); break; case 2: system("cls"); m.logout(); return booking(); break; case 3: system("cls"); cout<<"You are Lgging in as a non member so \n"; cout<<"1- Give us your required informations(so that we can add you to our member list ) \n"; cout<<"2- Set your user name and passward \n"; cout<<"3- Then enter your user name and passward to login\n\n"; m.nonuserlogin(); while(getche() != '\r'); return booking(); break; case 4: system("cls"); m.showloggedin_mem(); while(getche() != '\r'); return booking(); break; case 5: system("cls"); m.showloggedout_mem(); while(getche() != '\r'); return booking(); break; case 6: return cafe_managmentfun(); break; default: cout<<"Invalid choice ! Renter "; return booking(); break; } } void valid() { while(1) { cout << "\t\t\t\t Select Your Choice ->> "; cin>>choice; if(cin.good()) break; cin.clear(); cout<<"\t\t\tInvalid choice enter a valid choice"<<endl; cin.ignore(10,'\n'); } }
Write, Run & Share C++ code online using OneCompiler's C++ online compiler for free. It's one of the robust, feature-rich online compilers for C++ language, running on the latest version 17. Getting started with the OneCompiler's C++ compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as C++
and start coding!
OneCompiler's C++ online compiler supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample program which takes name as input and print your name with hello.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string name;
cout << "Enter name:";
getline (cin, name);
cout << "Hello " << name;
return 0;
}
C++ is a widely used middle-level programming language.
When ever you want to perform a set of operations based on a condition If-Else is used.
if(conditional-expression) {
//code
}
else {
//code
}
You can also use if-else for nested Ifs and If-Else-If ladder when multiple conditions are to be performed on a single variable.
Switch is an alternative to If-Else-If ladder.
switch(conditional-expression){
case value1:
// code
break; // optional
case value2:
// code
break; // optional
......
default:
code to be executed when all the above cases are not matched;
}
For loop is used to iterate a set of statements based on a condition.
for(Initialization; Condition; Increment/decrement){
//code
}
While is also used to iterate a set of statements based on a condition. Usually while is preferred when number of iterations are not known in advance.
while (condition) {
// code
}
Do-while is also used to iterate a set of statements based on a condition. It is mostly used when you need to execute the statements atleast once.
do {
// code
} while (condition);
Function is a sub-routine which contains set of statements. Usually functions are written when multiple calls are required to same set of statements which increases re-usuability and modularity. Function gets run only when it is called.
return_type function_name(parameters);
function_name (parameters)
return_type function_name(parameters) {
// code
}