ATM machine program in C++ using functions
Automated Teller Machines (ATMs) carry out daily financial transactions. They are straightforward and simple, allowing customers to complete self-service transactions quickly. ATMs can then be used to withdraw cash, deposit money, or obtain account information such as the balance amount, among other things.
In this article, we will look at the ATM Management System in C++, which is a system that gives user’s access to all of the features that a real Automated Teller Machine, or ATM, should have. It is menu-driven software with ATM features such as:
- To be displayed during transactions, enter your name, account number, and account type.
- The information about the individual who is conducting the transaction is displayed.
- Fill in the amount that will be placed in the account.
- The account's balance is displayed.
- After entering the amount to be drawn from the account, the available balance is displayed.
- The transaction is to be cancelled.
ATM will perform all these tasks.
This program employs fundamental concepts such as class, C++ Access Modifiers, different data types, variables, Switch Case, etc. The following are the features that will be implemented:
setval(): This function sets the data using the basic input and output methods in C++, namely the cout and cin statements, which show and take input from the keyboard, respectively.
The function showval() is used to print the data.
Deposit() is a function that allows you to deposit money into a certain account.
viewbal(): This function displays the total balance after making a deposit.
Withdrawl(): This function aids in withdrawing funds from a bank account.
Main (): This function has a simple switch case (to make selections) within an indefinite while loop, allowing the user to select options at any moment.
Code: -
#include <iostream>
#include <stdlib.h>
#include <string.h>
using namespace std;
class Bank {
private:
string name;
int accnumber;
char type[10];
int amount = 0;
int tot_bal = 0;
public:
void setval()
{
cout << "Enter name\n";
cin.ignore();
getline(cin, name);
cout << "Enter Account number\n";
cin >> accnumber;
cout << "Enter Account type\n";
cin >> type;
cout << "Enter Balance\n";
cin >> tot_bal;
}
void showdata()
{
cout << "Name:" << name << endl;
cout << "Account No:" << accnumber << endl;
cout << "Account type:" << type << endl;
cout << "Balance:" << tot_bal << endl;
}
void deposit()
{
cout << "\nEnter amount to be Deposited\n";
cin >> amount;
}
void viewbal()
{
tot_bal = tot_bal + amount;
cout << "\nTotal balance is: " << tot_bal;
}
void withdrawl()
{
int a, avail_balance;
cout << "Enter amount to withdraw\n";
cin >> a;
avail_balance = tot_bal - a;
cout << "Available Balance is" << avail_balance;
}
};
int main()
{
Bank b;
int choice;
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;
switch (choice) {
case 1:
b.setval();
break;
case 2:
b.showdata();
break;
case 3:
b.deposit();
break;
case 4:
b.viewbal();
break;
case 5:
b.withdrawl();
break;
case 6:
exit(1);
break;
default:
cout << "\nInvalid choice\n";
}
}
}
atm-machine-program-in-cpp-using-functions1
Output: -






In the above example, we have developed an ATM machine code and did the functioning of actual ATM machine of depositing, withdrawing and showing bank details like name, account number, type of account and the total balance.
So there are 6 option , 1st for entering details of customer, 2nd for viewing balance, 3rd for depositing the money , 4th for showing the total balance in the account , 5th for with drawing the amount from bank and 6th for cancelling the transaction of exiting the program.
Here in the screenshot all the options are displayed.
In the 2nd screenshot the details filled by customer are displayed and current balance is displayed.
In the 3rd screenshot the amount to be deposit is entered and displayed.
In the 4th screenshot the total balance of the customer is displayed.
In the 5th screenshot the amount to be withdrawn from the amount is entered and after withdrawing the balance amount is also displayed.
In the 6th screenshot the choice for cancelling the transaction or for exiting the program.