top of page

Process Simulation of ATM Financial Transactions using C++

  • Writer: LA Nuñez
    LA Nuñez
  • Feb 28, 2022
  • 5 min read

Updated: Feb 28, 2022


Automated teller machine (ATM) is a computerized telecommunications device that provides the customers of a financial institution with access to financial transactions in a public space without the need for a human clerk or bank teller. Using an ATM, customers can access their bank accounts in order to make cash withdrawals and check their account balances. However modern ATM also provides means of depositing to an account and pays some banking institution also allows customer to pay bills through the machine.


This machine problem would like to simulate the process of how an ATM provides financial transactions limited to checking of balance, withdrawing valid amount, and making deposit. Provide a menu similar to a regular ATM with proper directions for the customers to follow. Take into considerations the limitations of the different transactions that this program will provide. Make at least three different accounts.


This was the very first programming project I handled during my Bachelor's degree. In retrospect it was so easy to do, but then, it was such a big project that I can barely comprehend. Funny too, I remember finishing this program with just a mobile C++ compiler as my very first laptop gave up on me just before we get to start with the project.


That 200+ line of codes was already fulfilling for me to see fit and working. My groupmates and I, at that time after the presentation, really felt like it was our graduation; but of course it was just the beginning. To be honest, out of the four of us, I was the only one left to finish Information Technology. Regardless, wherever they are, I'm glad that we were able to work the project out, no matter how inexperienced we were. Norls, Ally, and Thea... they were the first ones who got my back when I was just starting my IT journey; and I could never be more thankful enough for how they expanded my idea about IT -- that it is not just 1s and 0s; not just syntax and symbols... programming can be fun, you just have to know how to be creative.


Output and Codes

Enter the PIN:

If incorrect, the program will ask to re-enter the correct pin. After the third failed attempt the program will exit.

If the PIN is correct, display the menu.


Here is the source code we used to accept user input for the PIN and validate it.

int main() {
	int i = 0;
	do
	{
		string pin_number;

		cout << "\nEnter PIN number: ";
		cin >> pin_number;

		if (pin_number == "1111")
		{
			cout << "\n\nClient Profile: Bibe Wan";
			menu();
			break;
		}
		else if (pin_number == "2222")
		{
			cout << "\n\nClient Profile: Bibe Tu";
			menu();
			break;
		}
		else if (pin_number == "3333")
		{
			cout << "\n\nClient Profile: Bibe Tri";
			menu();
			break;
		}
		else
		{
			cout << "\nInvalid PIN\n";
			i++;
		}
	} while (i <= 2);

	if (i > 2)
	{
		cout << "\nMaximum tries reached!\n";
		exit();
	}

	system("pause");
}


If the user selects B, display the current balance of the user.

The current is PHP 1000

Do you want to do another transaction[y/n]?

If yes, then show again the main menu, otherwise exit the program.


This is the source code we used under case 'B' or when the user input is equal to 'B'. This means that the user wants to check their current balance. As you can notice, this snippet is part of a switch block.

case 'B':

		cout << "\nThe Current Balance is Php " << balance;
		cout << "\n\nDo you want another transaction? [y/n]:\t";
		cin >> add_transaction1;
		if (add_transaction1 == 'y') { menu(); }
		else if (add_transaction1 == 'n') { exit(); }
		else { cout << "\n-Invalid Input-\n"; exit(); }
		break;

If the user selects W

Enter the amount to be withdrawn: 50

Sorry the amount should be divisible by 100 and not low than 100.

Enter the amount to be withdrawn: 120

Sorry the amount should be divisible by 100.

Enter the amount to be withdrawn: 1200

Sorry the amount should be within your current balance.

Enter the amount to be withdrawn: 500

Transaction completed.

Do you want to do another transaction[y/n]?

If yes, then show again the main menu, otherwise exit the program.


This is the snippet for 'W'. It means that the user wants to withdraw from their accounts.

case 'W':

		do {
			cout << "\nEnter the amount to be withdrawn: ";
			cin >> with_amount;
			w++;

			if (with_amount < 100)
			{
				cout << "Sorry the amount should be divisible by 100 and not lower than 100.\n";
			}
			else if (with_amount % 100 != 0)
			{
				cout << "Sorry the amount should be divisible by 100\n";
			}
			else if (with_amount > balance)
			{
				cout << "Sorry the amount should be within your current balance.\n";
			}
			else
			{
				cout << "\nTransaction completed!\n";
				balance = balance - with_amount;
				break;
			}
		} while (w <= 5);

		if (w > 5)
		{
			cout << "\n\nExceed Limit!"; exit();
		}

		cout << "\n\nDo you want another transaction? [y/n]:\t";
		cin >> add_transaction1;

		if (add_transaction1 == 'y')
		{
			menu();
		}
		else if (add_transaction1 == 'n')
		{
			exit();
		}
		else
		{
			cout << "\n-Invalid Input-\n"; exit();
		}

		break;


If the user selects D

This machine accepts bills only.

Enter deposit amount: 540

Transaction completed.


Do you want to do another transaction[y/n]?

If yes, then show again the main menu, otherwise exit the program.


This block is for adding money for to their account. As user chooses transaction 'D', the idea is that they will be able to deposit into their account.

case 'D':

		cout << "\nThis machine accept bills only.\n\n";
		do
		{
			cout << "\nEnter Deposit Amount: Php ";
			cin >> dep_amount;
			s++;
			if ((dep_amount % 20 != 0) && (dep_amount % 50 != 0) && (dep_amount % 100 != 0) && (dep_amount % 200 != 0) && (dep_amount % 500 != 0) && (dep_amount % 1000 != 0))
			{
				cout << "\nSorry but this machine accepts BILLS ONLY!\n";
			}
			else if (dep_amount < 100)
			{
				cout << "Sorry the amount should be divisible by 100 and not lower than 100.\n";
			}
			else if (dep_amount % 100 != 0)
			{
				cout << "Sorry the amount should be divisible by 100\n";
			}
			else if (dep_amount > balance)
			{
				cout << "Sorry the amount should be within your current balance.\n";
			}
			else
			{
				balance = balance + dep_amount;
				cout << "\nTransaction Complete!\n";
				break;
			}
		} while (s <= 5);

		if (s > 5)
		{
			cout << "\n\nExceed Limit!"; exit();
		}
		cout << "\n\nDo you want another transaction? [y/n]:\t";
		cin >> add_transaction1;

		if (add_transaction1 == 'y')
		{
			menu();
		}
		else if (add_transaction1 == 'n')
		{
			exit();
		}
		else
		{
			cout << "\n-Invalid Input-\n"; exit();
		}

		break;

If the user selects X

Thank you for Banking with Us. Have a nice day.


Lastly, to exit the program, we called the exit function in the case 'X' of the switch block.

case 'X':

		exit();
		break;

void exit()
{
	cout << "\n\nThank you for Banking with Us. Have a nice day.\n\n";
	return;
}

Notes

There were loads of other ways to do an ATM transaction. One can utilize the use of function, some can even make use object oriented programming, and or use abstract data type if they want to. This was coded back when I was just starting to code with C++ (or in programming in general).

It is by fault that we can realize a mistake; we can learn. I am glad that I learned a lot and got this far.

Authors

LA Nuñez, Norleen Joyce Lloren, Thea Clarisse Navarro, Alliah Tenedero



Comments


© 2023 by LA Nuñez

​エルエイ・ヌネズ

  • LinkedIn
  • YouTube
  • Twitter
  • Instagram
  • kisspng-social-media-github-computer-icons-logo-github-5ac01880ad2ac8_edited_edited_edited
bottom of page