Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <string>
- using namespace std;
- int deposit(int x, int y)
- {
- int newbal = x + y;
- return newbal;
- }
- int withdraw(int x, int y)
- {
- int newbal = x - y;
- return newbal;
- }
- int main()
- {
- int menu;
- int selection;
- double x = 1000, y;
- int trans;
- char user[20], pass[20], pktc[3];
- string newuser, newpass;
- do{
- system ("CLS");
- cout << "Welcome To Bank" << endl;
- cout << "[1] Register" << endl;
- cout << "[2] Login" << endl;
- cout << "[3] Exit" << endl;
- cout << "nnEnter command: " <<endl;
- cin >> menu;
- switch(menu)
- {
- //----------------------------------------------------------------CASE 1------------------------------------------------------------------------------//
- //----------------------------------------------------------------REGISTER----------------------------------------------------------------------------//
- case 1:
- system ("CLS");
- cout << "<-------REGISTER------->nn";
- cout << "Enter Name: ";
- cin >> user;
- newuser = user;
- cout << "Enter Password: ";
- cin >> pass;
- newpass = pass;
- cout <<"REGISTERED SUCCESSFULLY!" << endl;
- cout <<"nnPress Any key to contniue" << endl;
- cin >> pktc;
- system ("CLS");
- break;
- //------------------------------------------------------------END OF REGISTER--------------------------------------------------------------------------//
- //----------------------------------------------------------------CASE 2------------------------------------------------------------------------------//
- //-----------------------------------------------------------------LOGIN------------------------------------------------------------------------------//
- case 2:
- system ("CLS");
- cout << "<-------LOGIN------->nn";
- cout << "Enter Username: ";
- cin >> newuser;
- cout << "Enter Password: ";
- cin >> newpass;
- if(newuser != user || newpass != pass)
- {
- //-------------------------------------------------------------FAILED LOGIN----------------------------------------------------------------------------//
- cout << "nInvalid account" << endl;
- cout <<"nnPress Any key to contniue" << endl;
- cin >> pktc;
- system ("CLS");
- }
- else if (newuser == user || newpass == pass)
- {
- //----------------------------------------------------------------CASE 2.1------------------------------------------------------------------------------//
- //------------------------------------------------------------SUCCESFULL LOGIN--------------------------------------------------------------------------//
- system ("CLS");
- cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
- cout<<"nWelcome To Banco De Nelio";
- cout<<"nUSERNAME: "<< user << endl;
- cout<<"nn TIP ATM MACHINE";
- cout<<"n 1. Balance";
- cout<<"n 2. Deposit";
- cout<<"n 3. Withdraw";
- cout<<"n 4. Exit";
- do{
- cout<<"nnChoose Transaction[1-3]:";
- cin>>trans;
- switch(trans)
- {
- //----------------------------------------------------------------ATM CASE 1------------------------------------------------------------------------------//
- //--------------------------------------------------------------CHECK BALANCE--------------------------------------------------------------------------//
- case 1:
- system ("CLS");
- cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
- cout<<"nWelcome To Banco De Nelio";
- cout<<"nUSERNAME: "<< user << endl;
- cout<<"nn TIP ATM MACHINE";
- cout<<"n 1. Balance";
- cout<<"n 2. Deposit";
- cout<<"n 3. Withdraw";
- cout<<"n 4. Exit";
- cout<<"nnYour total balance is: "<< deposit(x, y) ;
- break;
- //----------------------------------------------------------------ATM CASE 2------------------------------------------------------------------------------//
- //--------------------------------------------------------------BEFORE DEPOSIT--------------------------------------------------------------------------//
- case 2:
- system ("CLS");
- cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
- cout<<"nWelcome To Banco De Nelio";
- cout<<"nUSERNAME: "<< user << endl;
- cout<<"nn TIP ATM MACHINE";
- cout<<"n 1. Balance";
- cout<<"n 2. Deposit";
- cout<<"n 3. Withdraw";
- cout<<"n 4. Exit";
- cout<<"nnEnter the amount:" ;
- cin>>y;
- //--------------------------------------------------------------AFTER DEPOSIT--------------------------------------------------------------------------//
- system ("CLS");
- cout << "nn<-------------------------------WELCOME------------------------------->nn" << endl;
- cout<<"nWelcome To Banco De Nelio";
- cout<<"nUSERNAME: "<< user << endl;
- cout<<"nn TIP ATM MACHINE";
- cout<<"n 1. Balance";
- cout<<"n 2. Deposit";
- cout<<"n 3. Withdraw";
- cout<<"n 4. Exit";
- cout<<"nnYour total balance now is: " << deposit(x, y) <<endl;
- break;
- //----------------------------------------------------------------ATM CASE 3------------------------------------------------------------------------------//
- //--------------------------------------------------------------WITHDRAW BALANCE--------------------------------------------------------------------------//
- case 3:
- cout<<"nEnter the amount:" ;
- cin>>y;
- if ( y > x)
- {
- cout<<"nYou cannot withdraw " << y;
- cout<<" because the amount is higher than your balance" << endl;
- break;
- }
- else
- x = x - y;
- cout<<"nYour Total Balance is now " << withdraw(x, y) << endl;
- break;
- //----------------------------------------------------------------ATM CASE 4------------------------------------------------------------------------------//
- //-------------------------------------------------------------------BACK--------------------------------------------------------------------------------//
- case 4:
- cout<<"nnThank You!" << endl;
- break;
- default:
- cout<<"nYou did not enter any valid number" << endl;
- break;
- }
- }while (trans<=3);
- }
- break;
- //----------------------------------------------------------------CASE 3------------------------------------------------------------------------------//
- //-----------------------------------------------------------------EXIT-------------------------------------------------------------------------------//
- case 3:
- system ("CLS");
- cout << "Thank you for using me!n";
- return 0;
- //-------------------------------------------------------------END OF EXIT----------------------------------------------------------------------------//
- }
- }while (menu<=3);
- }
- int add(int x,int y) { return a+b; }
- int sub(int x,int y) { return a-b; }
- int main() {
- int initial = 0;
- // add 10 then subtract 5
- std::cout << add(initial,10) << 'n'; // prints 10
- std::cout << sub(initial,5) << 'n'; // prints -5
- }
- int main() {
- int initial = 0;
- // add 10 then subtract 5 and update initial
- initial = add(initial,10);
- std::cout << initial << 'n';
- initial = sub(initial,5);
- std::cout << initial << 'n';
- }
Add Comment
Please, Sign In to add comment