In this article, we will build an ATM machine program in C++ that will have all the basic functionalities of an ATM. This project is good for someone having beginner to intermediate knowledge of C++ language. If you have a basic understanding of how arithmetic operations and functions work you will be able to easily follow this article.
Features
- The user can enter his account number and PIN to use the ATM (default account number is 12345 and PIN is 55555
- Users can withdraw cash and Deposit cash
- Users can also view the current balance
- Transfer cash from his account to another
Complete Code for ATM machine program in C++
We will use Code::Blocks IDE to develop this application. Open the Code::Blocks IDE and create a new project with the name atmsimulation, now in the main.cpp file paste the following code and run it.
#include <iostream> #include <iomanip> #include <stdlib.h> #include <string> #include <conio.h> #include <time.h> #include <string.h> using namespace std; void showMenu(); void welcomeScreen(); void receipt(); void showLogo(); void waiting(unsigned int mseconds) { clock_t goal = mseconds + clock(); while (goal > clock()); } int main() { int amount=10000; int choice, account; string pin = ""; char ast; cout << fixed << showpoint << setprecision(2); welcomeScreen(); system("cls"); showLogo(); cout << "\n\n\t\t\t Please type your Bank Account Number : "; cin >> account; cout << "\n\t\t\t Please type Personal Identification Number(PIN) : "; ast = _getch(); //cin >> pin; while(ast!=13) { pin.push_back(ast); cout << '*'; ast = _getch(); } if (account!=12345 && pin!="55555") { cout << "\n\t\t\tInvalid Bank Account and PIN. Please try again!"<<endl; getch(); } else { do { showMenu(); cin >> choice; while (choice < 1 || choice > 5) { cout << "\n\t\t\tPlease enter your choice 1, 2, 3, 4, or 5: "; cin >> choice; } int withdrawChoice, depositChoice; int checkBalanceChoice, fundsTransferChoice; double money = 0.0; char conf; if (choice==1) { system("cls"); showLogo(); cout <<"\t\t\t WITHDRAWAL TRANSACTION "<<endl; cout << "\n\n\t\t\t [ 1 ] From Savings" << endl; cout << "\t\t\t [ 2 ] Quick Cash" << endl; cout << "\t\t\t [ 3 ] Back to Main Menu" << endl; cout << "\t\t\t _____________________________________________"<<endl; cout << "\t\t\t Enter your withdraw transaction: "; cin >> withdrawChoice; while (withdrawChoice <1 || withdrawChoice >4 ) { system("cls"); showLogo(); cout << endl <<" \t\t\t WITHDRAWAL TRANSACTION "; cout << "\n\n\t\t\t Invalid Transaction!\n\t\t\t Please re-enter 1, 2, 3 or 4 : "; cin >> withdrawChoice; } if (withdrawChoice == 3) { showMenu(); } //Quick Cash else if (withdrawChoice == 2) { int amount1; system("cls"); showLogo(); cout<<"\n\t\t\t QUICK CASH TRANSACTION "<<endl; cout <<"\n\n\t\t\t REMAINING BALANCE : "<<amount<<endl; cout <<"\n\t\t\t Enter the Amount () : "; cin >> amount1; cout << "\n\t\t\t Your remaining quick cash balance: "<<10000 - amount1<<endl; waiting(3000); receipt(); cout << "\n\t\t\tTRANSACTION: QUICK WITHDRAWAL "<<endl; cout<< "\n\t\t\tAMOUNT: "<<amount1<<".00 "<<endl; cout<< "\n\t\t\tCURRENT BAL: "<<20000 - amount1<<".00 "<<endl; cout<< "\n\t\t\tAVAILABLE BAL: "<<20000 - amount1<<".00 "<<endl; waiting(5000); amount = amount - amount1; showMenu(); } else if (withdrawChoice == 1) { int amount2; system("cls"); showLogo(); cout<<"\n\t\t\t CASH SAVINGS TRANSACTION "<<endl; cout << "\n\n\t\t\t AVAILABLE BALANCE : "<<amount << endl; cout << "\t\t\t Enter the amount : "; cin >> amount2; cout << "\t\t\t Your remaining savings balance: "<<10000 - amount2<<endl; waiting(5000); system("cls"); receipt(); cout <<"\n\t\t\t TRANSACTION: SAVINGS WITHDRAWAL "<<endl; cout<< "\n\t\t\t AMOUNT: "<<amount2<<".00\t "<<endl; cout<< "\n\t\t\t CURRENT BAL: "<<20000 - amount2<<".00 "<<endl; cout<< "\n\t\t\t AVAILABLE BAL: "<<20000 - amount2<<".00 "<<endl; waiting(5000); amount = amount - amount2; showMenu(); } } else if(choice==2) { system("cls"); showLogo(); cout <<" \t\t\t DEPOSIT TRANSACTION "<<endl; cout << "\n\n\t\t\t [ 1 ] To Savings" << endl; cout << "\t\t\t [ 2 ] Back to Main Menu" << endl; cout << "\t\t\t _____________________________________________"<<endl; cout << "\t\t\t Enter your deposit transaction: "; cin >> depositChoice; while (depositChoice < 1 || depositChoice > 3) { system("cls"); showLogo(); cout << endl <<" \t\t\t DEPOSIT TRANSACTION "; cout << "\n\n\t\t\t Invalid Transaction!\n\t\t\t Please re-enter 1, 2 or 3 : "; cin >> depositChoice; } if (depositChoice == 2) { showMenu(); } else if (depositChoice == 1) { int depamount1; system("cls"); showLogo(); cout << endl <<" \t\t\t SAVINGS DEPOSIT TRANSACTION "; cout << "\n\n\t\t\t Enter the deposit amount : "; cin >> depamount1; amount = amount+depamount1; cout << "\t\t\t Your New Balance: "<<amount<<endl; waiting(5000); system("cls"); showMenu(); } } else if (choice==3) { system("cls"); showLogo(); cout <<" \t\t\t CHECK BALANCE TRANSACTION "<<endl; cout << "\n\n\t\t\t [ 1 ] From Savings" << endl; cout << "\t\t\t [ 2 ] Back to Main Menu" << endl; cout << "\t\t\t _____________________________________________"<<endl; cout << "\t\t\t Enter Your Check Balance Choice: "; cin >> checkBalanceChoice; while (checkBalanceChoice < 1 || checkBalanceChoice > 3) { system("cls"); showLogo(); cout << endl <<" \t\t\t CHECK BALANCE TRANSACTION "; cout << "\n\n\t\t\t Invalid Transaction!\n\t\t\t Please re-enter 1, 2 or 3 : "; cin >> checkBalanceChoice; } if (checkBalanceChoice == 2) { showMenu(); } else if (checkBalanceChoice ==1) { system("cls"); showLogo(); cout << endl <<" \t\t\t BALANCE SAVINGS TRANSACTION "; cout << "\n\n\t\t\t NEW AVAILABLE BALANCE : "<<amount<<endl; waiting(3000); showMenu(); } } else if (choice==4) { system("cls"); showLogo(); cout <<" \t\t\t FUND TRANSFER TRANSACTION "<<endl; cout << "\n\n\t\t\t [ 1 ] Transfer from Savings Account" << endl; cout << "\t\t\t [ 2 ] Back to Main Menu" << endl; cout << "\t\t\t _____________________________________________"<<endl; cout << "\t\t\t Enter Your Funds Transfer Transaction: "; cin >> fundsTransferChoice; while (fundsTransferChoice < 1 || fundsTransferChoice > 3) { system("cls"); showLogo(); cout << endl <<" \t\t\t FUND TRANSFER TRANSACTION "; cout << "\n\n\t\t\t Invalid Transaction!\n\t\t\t Please re-enter 1, 2 or 3 : "; cin >> fundsTransferChoice; } if (fundsTransferChoice == 2) { showMenu(); } else if (fundsTransferChoice ==1) { int accntNo, checkNo, amntNo; system("cls"); showLogo(); cout << endl <<" \t\t\t SAVINGS TRANSFER TRANSACTION"; cout << "\n\n\t\t\t NEW SAVINGS BALANCE : "<<amount; cout << "\n\t\t\t Account Number (for Transfer) : "; cin >> accntNo; cout << "\n\t\t\t Amount Transfer : "; cin >> amntNo; while (amntNo < 0 || amntNo > 10000) { system("cls"); showLogo(); cout << endl <<" \t\t\t SAVINGS TRANSFER TRANSACTION"; cout << "\n\n\t\t\t Invalid Amount!\n\t\t\t Please try again!"; cout << "\n\t\t\t Please enter Amount Transfer : "; cin >> amntNo; } waiting(1000); cout << "\n\n\t\t\t The amount of "<<amntNo<<" has been transfered to "<<accntNo; waiting(5000); amount = amount - amntNo; showMenu(); } } else if (choice ==5) { cout << " \n\t\t\t Invaild choice" << endl << endl; getch(); } } while (choice != 5); } return 0; } //Function to display the welcome screen void welcomeScreen() { cout<<"\n\t\t\t****************************************************"; cout<<"\n\t\t\t* WELCOME TO *"; cout<<"\n\t\t\t* ATM SIMULATION System *"; cout<<"\n\t\t\t****************************************************"; cout << "\n\n\n\n\n\n\t\t\tPlease INSERT your Card [Press ENTER to insert card] "<<endl; cin.get(); } //Function to display the logo void showLogo() { cout<<"\n\t\t\t****************************************************"; cout<<"\n\t\t\t* WELCOME TO *"; cout<<"\n\t\t\t* ATM SIMULATION System *"; cout<<"\n\t\t\t****************************************************"<<endl; } //Function to display the main menu void showMenu() { system("cls"); showLogo(); cout << endl <<" \t\t\t <<------------------ MAIN MENU TRANSACTION ------------------>>"; cout << "\n\n\t\t\t [ 1 ] Withdrawal" << endl; cout << "\t\t\t [ 2 ] Deposit" << endl; cout << "\t\t\t [ 3 ] Check Balance" << endl; cout << "\t\t\t [ 4 ] Funds Transfer" << endl; cout << "\t\t\t _____________________________________________"<<endl; cout << "\t\t\t Enter your choice: "; } //Function to display the receipt void receipt() { system("cls"); showLogo(); char date[9]; char time[9]; _strdate(date); _strtime(time); cout <<"\n\t\t\t PRINTING RECEIPT... "<<endl; waiting(3000); system("cls"); showLogo(); cout<<" \n\t\t\t THANKS FOR USING OUR SERVICE "<<endl; cout<< "\n\t\t\t---------------------------------------------"<<endl; cout<< "\n\t\t\t ATM TRANSACTION RECORD "<<endl; cout<< "\n\t\t\t----------------------------------------------"<<endl; cout<< "\n\t\t\t DATE: "<<date<<" "<<endl; cout<< "\n\t\t\t TIME: "<<time<<" "<<endl; cout<< "\n\t\t\t LOCATION: Mumbai "<<endl; cout<< "\n\t\t\t CARD NUM: ***********345 "<<endl; }
Output for ATM machine program in C++
Image Output:
Video Output:
Conclusion
In this article, we have built the ATM machine program in C++. This project provides all the features of an ATM system like withdrawing cash, depositing cash, checking the available amount, and transferring cash from one account to another. I hope this was easy to follow and that it helped you in some way.
Thank you for visiting our website.
Also Read:
- ChatGPT vs DeepSeek: Who is the winner?
- People are becoming AI Engineer with this free course in 2025: Here is how to join this…
- Apply to Google’s Student Training in Engineering Program (STEP) Intern, 2025
- Self-Driving Car Saves Falling Pedestrian, Showcases Promise of Autonomous Technology
- Instant Karma: Employer Fires Tech Team with AI, Faces Backlash on LinkedIn While Seeking New Developers
- LinkedIn’s COO Reveals the AI Interview Question That Could Land You the Job in 2025
- Elon Musk’s xAI Raises $6 Billion, Valued at $45 Billion
- Google Unveils Veo 2 and Imagen 3: A New Era of AI-Generated Content
- Imagination to Reality, Unlocking the Future: Genesis Physics Engine for 4D Simulation
- Simple Code to compare Speed of Python, Java, and C++?
- Falling Stars Animation on Python.Hub October 2024
- Most Underrated Database Trick | Life-Saving SQL Command
- Python List Methods
- Top 5 Free HTML Resume Templates in 2024 | With Source Code
- How to See Connected Wi-Fi Passwords in Windows?
- 2023 Merry Christmas using Python Turtle
- 23 AI Tools You Won’t Believe are Free
- Python 3.12.1 is Now Available
- Best Deepfake Apps and Websites You Can Try for Fun
- Amazon launched free Prompt Engineering course: Enroll Now
- 10 GitHub Repositories to Master Machine Learning
- Hello World in 35 Programming Languages
- How to Scrape Data From Any Website with Python?
- Become Job Ready With Free Harvard Computer Science course: Enroll Now
- Free Python Certification course from Alison: Good for Resume
- Download 1000+ Projects, All B.Tech & Programming Notes, Job, Resume & Interview Guide, and More – Get Your Ultimate Programming Bundle!
- Udacity Giving Free Python Course: Here is how to Enroll
- Love Babbar’s Income Revealed
- Top 5 Websites to Learn Programming in 2024
- Python Internship for college students and freshers: Apply Here