×

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:

  1. To be displayed during transactions, enter your name, account number, and account type.
  2. The information about the individual who is conducting the transaction is displayed.
  3. Fill in the amount that will be placed in the account.
  4. The account's balance is displayed.
  5. After entering the amount to be drawn from the account, the available balance is displayed.
  6. 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: -

ATM machine program in C++ using functions
ATM machine program in C++ using functions
ATM machine program in C++ using functions
ATM machine program in C++ using functions
ATM machine program in C++ using functions
ATM machine program in C++ using functions

 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.


Related Topics

Palindrome using For loop in C++

A palindrome is a word, number, phrase, or other sequence of letters that reads the same backward as forward, such as 101 or MOM. Like other programming languages, C++ also allows...

6 minutes read.

Top 14 Best Free C++ IDE (Editor & Compiler) for Windows in 2024

Bjarne Stroustrup created the all-purpose object-oriented programming language C++. To develop C++ programs, there are various Integrated Development Environments (IDE) that offer prewritten code templates. These programs automatically modify the...

6 minutes read.

fscanf() Function in the C++

In the C++ programming language, the fscanf() method can be used to read data from a file stream. Syntax: The syntax for the fscanf() function in the C++ programming language is as...

3 minutes read.

Pattern programs in C++

In this article, we are going to discuss different pattern programs in C++. Program for Printing * patterns: Right Angle Triangle* pattern #include <iostream> using namespace std; int main() {     int rows;     cout <<...

3 minutes read.

C++ Continue in for loop

Continue statement: Inside the loop, the continue statement is used to control the loop. C++ utilizes the continue keyword to implement the continue statement, which transfers the program's flow at the start...

4 minutes read.

C++ find missing in the second array

Given two arrays A and B of sizes n and m. Find the elements from array A that are not present in array B. Example Input : a[] = {1, 2, 3, 5,...

3 minutes read.

Implementation of a Falling Matrix in C++

In many Hollywood and Bollywood movies, we might have seen a programmer who will be referred to as a hacker all the time for some random reason which the writer...

3 minutes read.

Reverse a String using Stack C/C++

Reverse the given string using stack. To turn "tutorialandexample" into "elpmaxednalairotut," for instance. Here is a straightforward stack-based technique for reversing strings. Algorithm: 1) Make a stack that is empty. 2) Push each character...

3 minutes read.

Size_t Data Type in C++

In C++, the type to express the object size in bytes is defined as Size_t, an unsigned integer type offered by the standard library for describing the object's size and...

3 minutes read.

Reverse a Number in C++

In this tutorial, you'll learn how to utilize a C++ program to reverse a number entered by a user at runtime. Because there are various ways to write a C++...

3 minutes read.

Smart pointers in C++

What are Pointers ? Pointers are often used to keep track of a variable's address. A null value can be assigned to a pointer. Pass by reference can be used to...

6 minutes read.

Constructor Overloading

The program contains more than one constructor in a class with the same name, and different types of arguments are called constructor overloading. Calling of constructor depends on the number and types...

2 minutes read.

C++ Recursion Function

A programming method called recursion that uses a function to call itself to address lesser problems. The Fibonacci sequence, factorial computation, and tree traversal are just a few of the...

4 minutes read.

Depth First Search Program to Traverse a Graph in C++

Depth First Search (DFS) is a technique that is used for transversing the graph. The process of Depth First Search (DFS) starts from the root node and then next comes...

6 minutes read.

SDL library in C++ with Examples

SDL stands for Simple DirectMedia Layer. Using OpenGL and Direct3D, it is a cross-platform development library created to give users low-level access to audio, keyboard, mouse, joystick, and graphics hardware....

3 minutes read.

Timsort Implementation Using C++

Timsort Implementation Using C++ The Timsort is a stable sorting algorithm that uses the idea of merge sort and insertion sort. It can also be called a hybrid algorithm of insertion...

3 minutes read.

Decimal to Octal in C++

We must create a software that converts a decimal number into an equal octal number given a decimal number as input i.e. convert a number having a base value of...

3 minutes read.

C++ Program to Implement Merge Sort

C++ Program to Implement Merge Sort The technique of merge sort is based on the strategy of divide and conquer. We divide the set of while data into smaller bits, arranged...

3 minutes read.

Structured Binding in C++

Structured binding is the new feature of C++ 17. It is used to bind the specified name with an element of the initializer. Structure binding is used to declare multiple...

3 minutes read.

C++ Inheritance

What do you mean by Inheritance ? The ability to define new classes based on existing classes in order to reuse and organise code is referred to as inheritance. Single inheritance...

7 minutes read.