Question

In: Computer Science

Code C++ language description about Automated teller machine that can check balance, Deposit and Withdraw money

Code C++ language description about Automated teller machine that can check balance, Deposit and Withdraw money

Solutions

Expert Solution

#include

#include

#include

using namespace std;

 

void showLogin() {

    start:

        system("cls"); //system clear

        system("Color 0A"); //system color

    string username, password;

    char pw;

 

    cout << "*****************ANT ATM MACHINE*****************" << endl;

    cout << "Username: ";

    cin >> username;

    cout << "Password: ";

 

    while (pw = getch()) {

        if (pw == 13) {

            if ((username == "user") && (password == "user1234")) {

                break;

            }

            else {

                cout << "Invalid Input...";

                goto start;

            }

          } //13 is carriage return or enter from the keyboard

        else if (pw == 8) {

            if (sizeof(password) > 0) {

                cout << "\b \b";  //b is backspace on screen

                password.erase(password.length()-1);

            }

          } //8 is backspace or backspace from the keyboard

 

        else {

            cout << "*";

            password = password + pw; //password string & pw is a char

        }

    }

    system("cls");

}

 

void showMenu() {

    cout << "*****************ANT ATM MACHINE*****************" << endl;

    cout << "1. Check Balance" << endl;

    cout << "2. Deposit" << endl;

    cout << "3. Withdraw" << endl;

    cout << "4. Exit" << endl;

    cout << "*****************ANT ATM MACHINE*****************" << endl;

    system("Color 0A");

}

 

void option() {

    int option;

    double balance = 1000;

    double depositAmount, withdrawAmount;

 

    do {

        showMenu();

        cout << "Option: ";

        cin >> option;

        system("cls");

 

        switch (option) {

            case 1:

                cout << "Balance is: " << balance << "$" << endl << endl;

                break;

            case 2:

                cout << "Deposit Amount: ";

                cin >> depositAmount;

                if (depositAmount >= 0) {

                    cout << endl;

                    balance = balance + depositAmount; //balance += depositAmount

                }

                else {

                    cout << "Cannot Deposit Negative Amount of Money!" << endl << endl;

                }

                break;

            case 3:

                cout << "Withdraw Amount: ";

                cin >> withdrawAmount;

                if (withdrawAmount <= balance) {

                    cout << endl;

                    balance = balance - withdrawAmount; //balance -= withdrawAmount

                }

                else {

                    cout << "Not Enough Money!" << endl << endl;

                }

                break;

        }

    } while (option != 4);

 

    cout << "Thank you!!!" << endl;

}

 

int main() {

    showLogin();

    option();

    return 0;

}


Related Solutions

At Acme Bank the total amount of money that customers withdraw from an automatic teller machine...
At Acme Bank the total amount of money that customers withdraw from an automatic teller machine (ATM) each day is believed to be normally distributed with a mean of $8600 and a variance of 6250000. i) At the beginning of weekday (M-F), the Acme Bank puts $10000 into the automatic teller machine. What is the probability that the ATM becomes empty before the end of the day. ii) How much should the Acme Bank put in the ATM each day...
Code in C-language programming description about convert binary number to decimal number.
Code in C-language programming description about convert binary number to decimal number.
Code in C++ programming language description about read and write data to memory example.
Code in C++ programming language description about read and write data to memory example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived, sub) example.
Code in C++ programming language description about lesson Calculator (multiple, sum, dived,  sub) example.
Please code in C language. Server program: The server program provides a search to check for...
Please code in C language. Server program: The server program provides a search to check for a specific value in an integer array. The client writes a struct containing 3 elements: an integer value to search for, the size of an integer array which is 10 or less, and an integer array to the server through a FIFO. The server reads the struct from the FIFO and checks the array for the search value. If the search value appears in...
How to convert Sudo Code to C language? keyboard_process() {//insert a string. //check for shared memory...
How to convert Sudo Code to C language? keyboard_process() {//insert a string. //check for shared memory If(shared memory not full) { //sendthe string to the shared memory //send signal to process; }
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only)....
Translate the C function code below to the MIPS True Assembler Language code (machine instructions only). The function code should follow the conventions for MIPS function calls including passing parameters and returning results. Your function code must be written with the minimum number of machine instructions to be executed and without any use of MIPS pseudo-instructions. Myfunction(unsigned int a, unsigned int b, unsigned int c) { int i=0; while (a > c) { a /= b; i++; } return i;...
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Class object in C++ programming language description about lesson inheritance example.
Code in C++ programming language description about chose favorite fruit and wage color of fruit in lesson Class object (Multiple class).
Code in C++ programming language description about chose favorite fruit and wage  color of fruit in lesson Class object (Multiple class).
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT