×

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

Reverse function in C++

The function std::reverse() is included in the standard template library of C++. It takes in a beginning and ending iterator, reversing the order. To use the reverse statement, we need...

2 minutes read.

Reverse an Array in C++

The many approaches to reverse an array in the C++ programming language will be discussed in this section. The term "reverse of an array" refers to changing the order of...

8 minutes read.

Constructor Vs Destructor in C++

C++ Constructor A function Object () { [native code] } is a member function that shares the same name as the class. It is called automatically whenever a class object is...

3 minutes read.

Sizeof() Operators in C++

sizeof() Operators in C++ The sizeof() operator in C++ defines the size of variables, constants, or data types. It is a unique operator that manipulates other operators and returns the size...

4 minutes read.

C++ String Concatenation

C++ String Concatenation In this section, we will learn about C ++ String Concatenation, what it does, how it works, and will also see its programs. What is the String Concatenation? The + operator...

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.

C++ Aggregation

C++ Aggregation Definition: In C++, aggregation is a process in which one class (as an entity reference) defines another class. It provides another way to reuse the class. It represents...

4 minutes read.

Sum of all elements between k1’th and k2’th Smallest Elements

In this tutorial, we will look at how to determine sum of all given elements between two given indexes’ smallest elements. Assuming an array of integers and two numbers, k1...

2 minutes read.

C++ Queue

C++ queue: Queue in C++ is also a container adapter with the functionality of a queue. Queue is just the opposite of the stack in C++ because stack works on...

4 minutes read.

C++ Keywords

In this article, we will discuss keywords in C++ with their several features and functions. What are Keywords in C++? In C++, a keyword is a reserved word that has a predefined...

4 minutes read.

Inheritance and Friendship in C++

In this tutorial, we will look into what Inheritance and Friendship in C++ are, as well as the differences between the two. What is Inheritance in C++: In C++, inheritance is an...

2 minutes read.

C++ Do while loop

In this article, we will discuss the C++ Do-While loop with its syntax, working, key features, algorithm, and examples. Do-While Loop: The do-while loop constitutes a specific style of looping construct in...

5 minutes read.

C++ Fork

A new process known as a "child process" is created with the fork system function and runs concurrently with the process that invoked fork() (parent process). Both processes will carry...

4 minutes read.

C++ Range-based For Loop

In C++ language, the range-based for loop was added, which is far superior than the ordinary For loop. The implementation of a range-based for loop doesn't really need much code. It's a...

4 minutes read.

C++ Program For FCFS (First Come First Serve)

The most basic scheduling technique is FCFS, often known as "FIFO (First In, First Out)". In this procedure, the first one is utilized and executed first, while the second one...

4 minutes read.

Lambda Expression in C++

The lambda expression was introduced in C++ 11. It is used to write the inline function in C++. The code written in lambda expression cannot be reused further. The syntax...

3 minutes read.

C++ Polymorphism

Polymorphism refers to the fact that something exists in several forms. Polymorphism, in simple terms, is the ability of a message to be presented in several formats. A real-life example...

4 minutes read.

Decimal to Binary in C++

What is the meaning of Decimal Numbers? Decimal numbers range from 0 to 9, there are a total of ten digits between 0 and 9. Any number with more than two...

3 minutes read.

SET Data Structure in C++

Generally, in our home, we store food items in a fridge or kitchen efficiently to find them easily and use them. Similarly, in programming, we need to store the data...

6 minutes read.

Print Table Using For-loop in C++

Multiplication Table In mathematics, a table is created by multiplying a certain number by all of the counting numbers, i.e., 1, 2, 3, 4, 5, 6, and so on. It is...

3 minutes read.