Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ATM PROGRAM BY : ALJAN A. PORQUILLO
- BSCSSE - N01
- SUBMITTED TO: MRS. MAY D. SAN PABLO
- */
- #include <iostream>
- #include <Windows.h>
- using namespace std;
- // VARIABLE DECLARATIONS FOR NEW ACCOUNTS
- int a, b, y, z, x, cashin, balance = 0, passchoice, withdraw, cash , r, add_Bal, temp, password1 = 0, password[0], num5val = 0;
- char username[1000];
- char tempname[1000];
- int pin[100];
- int pin_check;
- // PRE DEFINE VARIABLE DECLARATIONS FOR OLD ACCOUNTS
- char predefUser;
- int uPass;
- int uPin;
- int uName;
- int u_Balance = 1000000, uAdd_bal, u_Withdraw, u_Temp, u_Cash, u_Cashin, u_A, pintemp, cPin1, cPin2, s, w, q;
- // PREDEFINED USER ID OF MAY
- int userPass = 333; // PREDEFINE USER PASSWORD
- int userPin = 1352; // PREDEFINE USER PIN
- // FUNCTION PROTOTYPING
- int main();
- int new_Menu();
- int myTrademark();
- int reg_newUser();
- int timer();
- int menu();
- int exit();
- int reg_oldUser();
- int old_Menu();
- int backtoMenu2();
- int myTrademark(){ // COMPANY NAME
- cout << " ----------------------------------" << endl;
- cout << "| F O R C E B A N K |" << endl;
- cout << "| |" << endl;
- cout << "| Owned by: Aljan Porquillo |" << endl;
- cout << " ----------------------------------" << endl;
- }
- int backtoMenu(){ // REDIRECTING FUNCTION FOR NEW ACCOUNTS
- cout << "\nRedirecting. please wait...";
- Sleep(3000);
- cout << "\n";
- }
- int backtoMenu2(){ // REDIRECTING FUNCTION FOR OLD ACCOUNTS
- cout << "\nRedirecting. please wait...";
- Sleep(3000);
- cout << "\n";
- return old_Menu();
- }
- int user_Input(){ // MENU INPUT
- myTrademark();
- cout << " [1] New User" << endl;
- cout << " [2] Registered User" << endl;
- cout << "\n ----------------------------------" << endl;
- cout << "Select user type: ";
- cin >> x;
- if(x==1){
- reg_newUser();
- }
- if (x==2){
- reg_oldUser();
- }
- if(x > 2){
- cout << "\n[Error]: You entered wrong input.\nwe're now redirecting you ";
- system("pause");
- system("cls");
- return main();
- }
- }
- int new_reg(){ // NEW ACCOUNT DIRECTING TO REGISTERED USER
- myTrademark();
- cout << " " << endl;
- cout << " ----------------------------------" << endl;
- cout << "| L O G I N |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "Enter Account name: ";
- cin >> tempname;
- cout << "Enter Password: ";
- cin >> password[3];
- cout << "Enter Pin: ";
- cin >> pin[4];
- if(tempname == username){
- if(password[0] == password[3] || pin[2] || pin[0] == pin[4]){
- cout << "Login successfully!" << endl;
- cout << "\nRedirecting. please wait...";
- Sleep(3000);
- new_Menu();
- }
- else{
- cout << "\n\nEither Account name, Password or Pin you've entered is incorrect." << endl;
- backtoMenu();
- system("cls");
- user_Input();
- }
- }
- }
- int reg_newUser(){ // NEW USER
- cout << "\n -------REGISTERING NEW USER-------" << endl;
- cout << "Username: ";
- cin >> username;
- cout << " ----------------------------------" << endl;
- cout << "| Register your pin |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "Enter pin: ";
- for(int i = 0; i < 1; i++){
- cin >> pin[0]; // pin 0 and pin 1 are same pin
- cout << " ----------------------------------" << endl;
- cout << "| Verify Pin |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "Enter pin: ";
- for(int j = 1; j < 2; i++){
- cin >> pin[1]; // pin 1 and pin 0 are same pin
- break;
- }
- }
- if(pin[0] == pin[1]){
- cout << " ----------------------------------" << endl;
- cout << "| Pin Verified! |" << endl;
- cout << "| You're now registered! |" << endl;
- cout << " ----------------------------------" << endl;
- backtoMenu();
- do{
- new_Menu();
- }
- while(true);
- }
- else{
- cout << "\n\nPin doesn't match!" << endl;
- backtoMenu();
- system("cls");
- myTrademark();
- reg_newUser();
- }
- }
- int reg_oldUser(){ // PRE DEFINED USER ACCOUNT
- myTrademark();
- cout << " " << endl;
- cout << " ----------------------------------" << endl;
- cout << "| L O G I N |" << endl;
- cout << " -------- Registered User ---------" << endl;
- cout << "Pin: ";
- cin >> uPin;
- cout << "Pass: ";
- cin >> uPass;
- if(uPass == userPass){
- if(userPin == uPin){
- cout << "\nLogin Successfully!" << endl;
- cout << "\nWelcome May!" << endl;
- cout << "Please wait a moment..." << endl;
- Sleep(3000);
- old_Menu();
- }
- else{
- cout << "\nError! wrong Pin" << endl;
- cout << "Redirecting. please wait..." << endl;
- Sleep(3000);
- return reg_oldUser();
- }
- }
- else{
- cout << "\nError! No Account associated with this Pin and Password!\n" << endl;
- cout << "Redirecting. please wait..." << endl;
- Sleep(3000);
- system("cls");
- return reg_oldUser();
- }
- }
- int old_Menu(){ // OLD USER MENU
- system("cls");
- cout << " ----------------------------------" << endl;
- cout << "| M E N U |" << endl;
- cout << "| |" << endl;
- cout << "| Select Process |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "[1] Deposit" << endl;
- cout << "[2] Withdraw"<< endl;
- cout << "[3] Balance Inquiry"<< endl;
- cout << "[4] Change Pin" << endl;
- cout << "[5] Logout" << endl;
- cout << "------------------------" << endl;
- cout << "Choose process number: ";
- cin >> x;
- if(x==1){
- if(x==1){ // DEPOSIT
- system("cls");
- myTrademark();
- cout << "\nWelcome May!" << endl;
- cout << " ---------+ DEPOSIT +----------\n" << endl;
- cout << "Balance: " << u_Balance << endl;
- cout << "\nEnter Amount to Deposit: ";
- cin >> uAdd_bal;
- u_Balance += uAdd_bal; // will add to current balance
- if(uAdd_bal > 0 || uAdd_bal != 0){
- cout << "------------------------------" << endl;
- cout << "\nYour deposit is successfully transacted!\n" << endl;
- cout << "Please wait a moment..." << endl;
- Sleep(3000);
- return old_Menu();
- }
- else{
- cout << "\nNo Deposit has been made" << endl;
- cout << "Please wait a moment..." << endl;
- Sleep(3000);
- return old_Menu();
- }
- }
- }
- if(x==2){ // WITHDRAW
- system("cls");
- myTrademark();
- cout << " ---------+ WITHDRAW +----------\n" << endl;
- if(u_Balance > 0 || u_Balance != 0){
- cout << "Current balance: " << u_Balance << endl;
- cout << "********************************" << endl;
- cout << "\nWithdraw amount: ";
- cin >> u_Withdraw;
- if(u_Withdraw <= u_Balance){
- cout << "\n[SUCCESFULLY WITHDRAWED!]" << endl;
- cout << "--------------------------------" << endl;
- u_Temp = u_Balance - u_Withdraw; // store to temporary variable in order to safely store current balance
- cout << "\nCurrent Balance " << u_Temp << endl;
- u_Balance -= u_Withdraw; // Minus to current balance
- return backtoMenu2(); // return
- }
- else if(u_Withdraw > u_Balance){
- cout << "\nYou can't withdraw, you have insufficient funds" << endl;
- return backtoMenu2();
- }
- }
- else if(u_Withdraw == 0 || u_Withdraw < 0){
- cout << " [YOU CAN'T WITHDRAW]" << endl;
- cout << "\nError: It seems you have insufficient enough balance.\nPlease top up." << endl;
- return backtoMenu2();
- }
- }
- if(x==3){
- if(x==3){ // BALANCE INQUIRY
- system("cls");
- myTrademark();
- cout << " ------+ BALANCE INQUIRY +-------\n" << endl;
- if(uAdd_bal > 0 || u_Balance != 0 || u_Balance > 0){
- cout << "Current Balance " << u_Balance << endl;
- return backtoMenu2();
- }
- else if(uAdd_bal == 0){
- cout << "Your account has insufficient funds" << endl;
- while(true){
- cout << "\n============ Add Funds ============\n" << endl;
- cout << "Do you want to add funds" << endl;
- cout << "-----------------------------------\n" << endl;
- cout <<"[1] YES [2] NO\n" << endl;
- cout << "-----------------------------------" << endl;
- cout << "Choose process number: ";
- cin >> z;
- if(z==1){
- cout << "Cash in amount: ";
- cin >> cashin;
- u_Cashin += u_Balance;
- u_A = u_Cash;
- u_Balance = u_A;
- if(u_Cashin > 0 || u_Balance != 0){
- cout << "\nYour deposit is successfully transacted!\n" << endl;
- return backtoMenu2();
- }
- }
- if(z==2){
- return old_Menu();
- }
- }
- }
- else{
- cout << "Your Balance is: " << balance << endl;
- system("pause"); // return
- }
- }
- }
- if(x==4){ // CHANGE PIN
- system("cls");
- myTrademark();
- cout << " --------+ CHANGE PIN +--------\n" << endl;
- cout << "Enter your pin: ";
- cin >> pintemp;
- if(pintemp == userPin){
- cout << " ----------------------------------" << endl;
- cout << "| Changing Pin |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "Enter pin: ";
- cin >> cPin1;
- cout << "Enter Pin Again: ";
- cin >> cPin2;
- if(cPin1 == cPin2){
- cout << "\nSuccessfully Pin Changed" << endl;
- cout << "\n[Note]: Account will Logout." << endl;
- // Swapping pin defined variables
- s = cPin1;
- q = s;
- userPin = q;
- }
- else{
- cout << "Pin Doesn't Matched! please try again." << endl;
- return backtoMenu2();
- }
- }
- else{
- cout << "Wrong Pin!";
- return backtoMenu2();
- }
- cout << "\nRe-Login your account" << endl;
- cout << "\nPlease wait a moment..." << endl;
- Sleep(3000);
- system("cls");
- return reg_oldUser();
- }
- if(x==5){ // LOGOUT
- system("cls");
- cout << "Account will Logout!" << endl;
- cout << "\nPlease wait a moment..." << endl;
- Sleep(5000);
- system("cls");
- return user_Input();
- }
- }
- int new_Menu(){ // NEW USER MENU
- system("cls");
- cout << " ----------------------------------" << endl;
- cout << "| M E N U |" << endl;
- cout << "| |" << endl;
- cout << "| Select Process |" << endl;
- cout << " ----------------------------------" << endl;
- cout << "[1] Deposit" << endl;
- cout << "[2] Withdraw"<< endl;
- cout << "[3] Balance Inquiry"<< endl;
- cout << "[4] Change Pin" << endl;
- cout << "[5] Validate" << endl;
- cout << "[6] Logout" << endl;
- cout << "------------------------" << endl;
- cout << "Choose process number: ";
- cin >> x;
- if(x==1){ // DEPOSIT
- system("cls");
- myTrademark();
- cout << "User: " << username << endl;
- cout << " ---------+ DEPOSIT +----------\n" << endl;
- cout << "Balance: " << balance << endl;
- cout << "\nEnter Amount to Deposit: ";
- cin >> add_Bal;
- balance += add_Bal; // will add to current balance
- if(add_Bal > 0 || add_Bal != 0){
- cout << "------------------------------" << endl;
- cout << "\nYour deposit is successfully transacted!\n" << endl;
- return backtoMenu(); // return
- }
- else{
- cout << "\nNo Deposit has been made" << endl;
- return backtoMenu();
- new_Menu();
- }
- }
- if(x==2){ // WITHDRAW
- system("cls");
- myTrademark();
- cout << " ---------+ WITHDRAW +----------\n" << endl;
- if(balance > 0 || balance != 0){
- cout << "Current balance: " << balance << endl;
- cout << "********************" << endl;
- cout << "\nWithdraw amount: ";
- cin >> withdraw;
- if(withdraw <= balance){
- cout << "\n[SUCCESFULLY WITHDRAWED!]" << endl;
- cout << "--------------------------------" << endl;
- temp = balance - withdraw; // store to temporary variable in order to safely store current balance
- cout << "\nCurrent Balance " << temp << endl;
- balance -= withdraw; // Minus to current balance
- return backtoMenu(); // return
- }
- else if(withdraw > balance){
- cout << "\nYou can't withdraw, you have insufficient funds" << endl;
- return backtoMenu(); // return
- }
- }
- else if(withdraw == 0 || withdraw < 0){
- cout << " [YOU CAN'T WITHDRAW]" << endl;
- cout << "\nError: It seems you have insufficient enough balance.\nPlease top up." << endl;
- return backtoMenu(); // return
- }
- }
- if(x==3){ // BALANCE INQUIRY
- system("cls");
- myTrademark();
- cout << " ------+ BALANCE INQUIRY +-------\n" << endl;
- if(add_Bal > 0 || balance != 0 || balance > 0){
- cout << "Current Balance " << balance << endl;
- return backtoMenu();
- }
- else if(add_Bal == 0){
- cout << "Your account has insufficient funds" << endl;
- while(true){
- cout << "\n============ Add Funds ============\n" << endl;
- cout << "Do you want to add funds" << endl;
- cout << "-----------------------------------\n" << endl;
- cout <<"[1] YES [2] NO\n" << endl;
- cout << "-----------------------------------" << endl;
- cout << "Choose process number: ";
- cin >> z;
- if(z==1){
- cout << "Cash in amount: ";
- cin >> cashin;
- cashin += balance;
- a = cash;
- balance = a;
- if(cashin > 0 || balance != 0){
- cout << "\nYour deposit is successfully transacted!\n" << endl;
- return backtoMenu();
- }
- }
- if(z==2){
- return new_Menu();
- }
- }
- }
- else{
- cout << "Your Balance is: " << balance << endl;
- system("pause"); // return
- }
- }
- if(x==4){ // CHANGE PIN
- system("cls");
- myTrademark();
- cout << " --------+ CHANGE PIN +--------\n" << endl;
- cout << "Enter your pin: ";
- cin >> pin_check;
- if(pin[0] != pin_check){
- cout << "Error!" << endl;
- }
- if(pin[0] == pin_check){
- cout << " ----------------------------------" << endl;
- cout << "| Changing Pin |" << endl;
- cout << " ----------------------------------" << endl;
- for(int i = 0; i < 1; i++){
- cout << "Enter pin: ";
- cin >> pin[2];
- for(int j = 0; j < 1; j++){
- cout << "Enter pin again: ";
- cin >> pin[3];
- }
- }
- if(pin[2] == pin[3]){
- cout << "\n[/] Pin Successfully Changed!" << endl;
- cout << "your new Pin is " << pin[2] << endl;
- }
- else{
- cout << "[X] Pin Doesn't Matched! please try again. " << endl;
- }
- }
- return backtoMenu();
- }
- if(x==5){ // VALIDATE
- system("cls");
- myTrademark();
- cout << "Account name: " << username << endl;
- if(password[0] > 0){
- cout << "Password " << password[0] << endl;
- }else{
- cout << "Password: NOT SET" << endl;
- }
- if(pin[0] > pin[2]){
- cout << "Pin: " << pin[1] << endl;
- }
- else{
- cout << "Pin: " << pin[2] << endl;
- }
- if (password1 == 0){
- cout << "\n\nYour account is weak and prone for skimming and hacking.\n";
- cout << "You wish to add password? \n";
- cout << "\n[1] YES [2] NO\n" << endl;
- cout << "=> ";
- cin >> passchoice;
- num5val = passchoice;
- if(passchoice != 2){
- cout << " ----------------------------------" << endl;
- cout << "| Add Password |" << endl;
- cout << " ----------------------------------" << endl;
- for(int i = 0; i < 1; i++){
- cout << "=> ";
- cin >> password[0];
- cout << " ----------------------------------" << endl;
- cout << "| Verify Password |" << endl;
- cout << " ----------------------------------" << endl;
- for(int j = 1; j < 2; j++){
- cout << "=> ";
- cin >> password[1];
- break;
- }
- }
- if(passchoice == 2){
- cout << "Warning! Account not validated!"<< endl;
- backtoMenu();
- }
- cout << "\nYour Account is now Validated!" << endl;
- backtoMenu();
- }
- }
- }
- if(x==6){ // LOGOUT
- if(password[1] == 0){
- cout << "\nYou can't Logout, if you haven't validate your account." << endl;
- backtoMenu();
- new_Menu();
- }
- else{
- cout << "\n[Note]: Validate your account in order to get verified and Login as Registered User" << endl;
- if(num5val > 0){
- cout << "Wish to proceed?" << endl;
- system("pause");
- cout << "You can now Login as Registered User" << endl;
- system("cls");
- new_reg();
- }
- else if(password){
- cout << "Account not yet validated! " << endl;
- }
- }
- }
- }
- int main(){
- user_Input();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement