C++ ATM Source Codes
C++ ATM Source Codes
C++ ATM Source Codes
1. #include <iostream>
2.
3. using namespace std;
4.
5. int main()
6. {
7. float Balance = 100.00;
8. int account_type, option;
9. float amount;
10. //Option Menu for Account type selection
11. cout << "Welcome To ATM" << endl << endl;
12. cout << "1) Current" << endl;
13. cout << "2) Saving" << endl;
14. //Prompting user to select account type
15. cout << "Please select account type (1 or 2): ";
16. cin >> account_type;
17. //If user enters option 1 or 2
18. if(account_type == 1 || account_type == 2)
19. {
20. //Display account operations options to user
21. cout << "1) Withdraw Amount" << endl;
22. cout << "2) Balance Inquiry" << endl;
23. //prompt user to select operation
24. cout << "Select an option (1 or 2): ";
25. cin >> option;
26. if(option == 1) //User want to withdraw
27. {
28. //prompt user to enter amount he/she want to withdraw
29. cout << "Please enter amount to withdraw : ";
30. cin >> amount;
31. if(amount <= 0) // if amount entered is zero or negative
display error
32. {
33. cout << "Amount can not be zero or negative" << endl;
34. }
35. else if(amount > Balance) // if amount to withdraw is greater
than account balance, display error
36. {
37. cout << "You do not have much funds to withdraw this amount"
<< endl;
38. }
39. else // withdraw funds and display user success message
40. {
41. Balance = Balance - amount;
42. cout << "Balance withdrawl successful!!!. Your new balance is
" << Balance << endl;
43. }
44.
45. }
46. else if(option == 2) // if user select option 2, display account
balance
47. {
48. cout << "Your Balance is " << Balance << endl;
49. }
50. else
51. {
52. cout << "Invalid Option Selected." << endl;
53. }
54. }
55. else //wrong account type entered, display error message
56. {
57. cout << "Invalid Account type selected." << endl;
58. }
59. cout << "Thank You Using Our ATM!" << endl;
60. return 0;
61. }
So far the atm works on run time. Every record is lose when the application is closed. I
would suggest to attach the atm system with a database. So that each and every record
can be retrieved and assessed at later stages.