Advertisement
albela

Untitled

Apr 18th, 2021
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.72 KB | None | 0 0
  1. // Q4.Write a program to display the ATM transaction using c++ programming.
  2. //Solution:-
  3.  
  4. #include <iostream>
  5. #include <cstdio>
  6.  
  7. using namespace std;
  8.  
  9. double balance=50000.00;
  10. int pass;
  11. int choice1;
  12.  
  13.  
  14.  
  15. int validatePassword(int);
  16. double getBalance();
  17. void Deposit(double);
  18. void Withdrawal(double);
  19. void choice();
  20.  
  21. int main()
  22. {
  23.     cout <<"   **Welcome to Canera Bank** " <<endl;
  24.     cout <<"   **AUTOMATED TELLER MACHINE** " <<endl;
  25.     cout <<" Welcome to Canera Bank Main Menu " <<endl;
  26.     cout <<" 1. Balance Enquiry" <<endl;
  27.     cout <<" 2. Deposit" <<endl;
  28.     cout <<" 3. Withdrawal" <<endl;
  29.     cout <<" 4. Quit" <<endl;
  30.     cin>>choice1;
  31.     choice();
  32.     return 0;
  33. }
  34.  
  35. void choice()
  36. {
  37.  
  38.    
  39.     if (choice1==1)
  40.         getBalance();
  41.     else if (choice1==2)
  42.         Deposit(balance);
  43.     else if (choice1==3)
  44.         Withdrawal(balance);
  45.     else if (choice1==4)
  46.  
  47.         cout <<"Quit" <<endl;
  48.     else
  49.         cout <<"Exit!" <<endl;
  50. }
  51.  
  52. int validatePassword(int)
  53. {
  54.     int Password=24680;
  55.     int pass;
  56.  
  57.     for (int i=0;i<3;i++)
  58.     {
  59.         cout <<" Please enter your password " <<endl;
  60.         cin >> pass;
  61.  
  62.         if (Password==24680)
  63.         {cout <<"1 = continue!" <<endl;
  64.         }
  65.         else
  66.         {
  67.             cout <<"0 = try again!" <<endl;
  68.         }
  69.     }
  70.     return 0;
  71. }
  72.  
  73. double getBalance()
  74. {
  75.     cout <<"The amount in your account is $" <<balance<<endl;
  76.  
  77.     return 0;
  78. }
  79.  
  80. void Deposit(double)
  81. {
  82.     double deposit;
  83.  
  84.     cout <<"Enter amount of your deposit :$ " <<endl;
  85.     cin >>deposit;
  86.     balance = balance + deposit;
  87.     cout <<"Your new balance is $ "<<balance <<endl;
  88. }
  89.  
  90. void Withdrawal(double)
  91. {
  92.     double withdrawal;
  93.  
  94.     cout <<"Enter amount of your withdrawal(max 50000) :$ " <<endl;
  95.     cin >>withdrawal;
  96.     balance = balance + withdrawal;
  97.     cout <<"Your new balance is $" <<(50000-withdrawal) <<endl;
  98. }
  99.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement