Creating an Simple ATM Interface in C++ with Free Codes

Introduction – ATM Interface

We are going to create ATM Interface which stands for Automated Teller Machine, Here we will simulate a basic ATM interface with functionalities like balance inquiry, deposit and withdrawal. Here is the simple overview and the formula we used for create this Project.

Overview – ATM Interface

The ATM interface will offer the following functionalities:

  1. Balance Inquiry
  2. Deposit
  3. Withdrawal
  4. Exit

The user selects a functionality, performs the corresponding action, and the program outputs the result.

Formulas for ATM Operations

-> Balance Inquiry: Simply display the current balance.

-> Deposit: Add the deposited amount to the current balance.

New Balance = Current Balance + Deposit Amount

-> Withdrawal: Subtract the withdrawal amount from the current balance (if sufficient funds are available).

New Balance = Current Balance − Withdrawal Amount

C++ Code for Project

Here is the Codes

#include <iostream>
using namespace std;

int main() {
    double balance = 1000.0; // Initial balance
    int choice;
    double amount;

    do {
        // Display ATM menu
        cout << "ATM Menu:" << endl;
        cout << "1. Balance Inquiry" << endl;
        cout << "2. Deposit" << endl;
        cout << "3. Withdrawal" << endl;
        cout << "4. Exit" << endl;
        cout << "Enter your choice: ";
        cin >> choice;

        switch(choice) {
            case 1:
                // Balance Inquiry
                cout << "Current Balance: $" << balance << endl;
                break;
            case 2:
                // Deposit
                cout << "Enter amount to deposit: $";
                cin >> amount;
                if (amount > 0) {
                    balance += amount;
                    cout << "Deposited: $" << amount << endl;
                    cout << "New Balance: $" << balance << endl;
                } else {
                    cout << "Invalid deposit amount!" << endl;
                }
                break;
            case 3:
                // Withdrawal
                cout << "Enter amount to withdraw: $";
                cin >> amount;
                if (amount > 0 && amount <= balance) {
                    balance -= amount;
                    cout << "Withdrawn: $" << amount << endl;
                    cout << "New Balance: $" << balance << endl;
                } else if (amount > balance) {
                    cout << "Insufficient funds!" << endl;
                } else {
                    cout << "Invalid withdrawal amount!" << endl;
                }
                break;
            case 4:
                // Exit
                cout << "Thank you for using the ATM. Goodbye!" << endl;
                break;
            default:
                cout << "Invalid choice! Please try again." << endl;
        }
        cout << endl;
    } while (choice != 4);

    return 0;
}

ATM Interface C++ Language

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top