Answer to Question #282237 in C++ for Hope

Question #282237

AUTOMATED TELLER MACHINE

Screen/layout

MAD AUTOMATED TELLER MACHINE IS ONLINE


INPUT YOUR 6 DIGIT PIN ******


ENTER[Y/N]: Y

(default PIN is mad123; if correct go to main screen otherwise display the message "WRONG PIN". On the 3rd wrong attempt the prog. should exit)


[C]HECK BALANCE

[D]EPOSIT CASH

[W]ITHDRAW CASH

C[H]ANGE PIN


TRANSACTION: [C|D|W|H]: C


YOUR CURRENT BALANCE IS:

Php 0.00

TRANSACTION: [C|D|W|H]: D


INSERT YOU CASH

Php 15,000.00


Transaction [C|D|W|H]: W


INPUT THE AMOUNT OF WITHDRAWAL

Php 20,000.00

CASH NOT ENOUGH, TRY AGAIN


INPUT THE AMOUNT OF WITHDRAWAL

Php 5,000.00


TRANSACTION: [C|D|W|H]: H


INPUT YOUR CURRENT PIN ******

INPUT YOUR NEW PIN ******

VERIFY YOUR NEW PIN ******


ENTER[Y/N]: Y


1
Expert's answer
2021-12-24T01:20:37-0500






// C++ program to implement the ATM

// Management System

#include <iostream>

#include <stdlib.h>

#include <string.h>

using namespace std;

class Bank {

 

    // Private variables used inside class

private:

    string name;

    int accnumber;

    char type[10];

    int amount = 0;

    int tot = 0;

 

    // Public variables

public:

    // Function to set the person's data

    void setvalue()

    {

        cout << "Enter name\n";

        cin.ignore();

 

        // To use space in string

        getline(cin, name);

 

        cout << "Enter Account number\n";

        cin >> accnumber;

        cout << "Enter Account type\n";

        cin >> type;

        cout << "Enter Balance\n";

        cin >> tot;

    }

 

    // Function to display the required data

    void showdata()

    {

        cout << "Name:" << name << endl;

        cout << "Account No:" << accnumber << endl;

        cout << "Account type:" << type << endl;

        cout << "Balance:" << tot << endl;

    }

 

    // Function to deposit the amount in ATM

    void deposit()

    {

        cout << "\nEnter amount to be Deposited\n";

        cin >> amount;

    }

 

    // Function to show the balance amount

    void showbal()

    {

        tot = tot + amount;

        cout << "\nTotal balance is: " << tot;

    }

 

    // Function to withdraw the amount in ATM

    void withdrawl()

    {

        int a, avai_balance;

        cout << "Enter amount to withdraw\n";

        cin >> a;

        avai_balance = tot - a;

        cout << "Available Balance is" << avai_balance;

    }

};

 

// Driver Code

int main()

{

    // Object of class

    Bank b;

 

    int choice;

 

    // Infinite while loop to choose

    // options everytime

    while (1) {

        cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~"

             << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

             << "~~~WELCOME~~~~~~~~~~~~~~~~~~"

             << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"

             << "~~~~~~~~~\n\n";

        cout << "Enter Your Choice\n";

        cout << "\t1. Enter name, Account "

             << "number, Account type\n";

        cout << "\t2. Balance Enquiry\n";

        cout << "\t3. Deposit Money\n";

        cout << "\t4. Show Total balance\n";

        cout << "\t5. Withdraw Money\n";

        cout << "\t6. Cancel\n";

        cin >> choice;

 

        // Choices to select from

        switch (choice) {

        case 1:

            b.setvalue();

            break;

        case 2:

            b.showdata();

            break;

        case 3:

            b.deposit();

            break;

        case 4:

            b.showbal();

            break;

        case 5:

            b.withdrawl();

            break;

        case 6:

            exit(1);

            break;

        default:

            cout << "\nInvalid choice\n";

        }

    }

}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog