fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int pin, choice;
  6. float balance = 5000, deposit, withdraw;
  7.  
  8. cout << "Enter your PIN: ";
  9. cin >> pin;
  10.  
  11. if (pin != 1234) {
  12. cout << "Incorrect PIN. Access denied." << endl;
  13. return 0;
  14. }
  15.  
  16. do {
  17. cout << "\n----- e-ATM Menu -----\n";
  18. cout << "1. Deposit Money\n2. Withdraw Money\n3. Check Balance\n4. Exit\n";
  19. cout << "Choose an option: ";
  20. cin >> choice;
  21.  
  22. switch (choice) {
  23. case 1:
  24. cout << "Enter deposit amount: R";
  25. cin >> deposit;
  26. balance += deposit;
  27. cout << "Deposit successful. New balance: R" << balance << endl;
  28. break;
  29. case 2:
  30. cout << "Enter amount to withdraw: R";
  31. cin >> withdraw;
  32. if (withdraw > balance)
  33. cout << "Insufficient funds." << endl;
  34. else {
  35. balance -= withdraw;
  36. cout << "Withdrawal successful. New balance: R" << balance << endl;
  37. }
  38. break;
  39. case 3:
  40. cout << "Current balance: R" << balance << endl;
  41. break;
  42. case 4:
  43. cout << "Thank you. Goodbye!" << endl;
  44. break;
  45. default:
  46. cout << "Invalid option. Try again." << endl;
  47. }
  48. } while (choice != 4);
  49.  
  50. return 0;
  51. }
  52.  
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
Enter your PIN: Incorrect PIN. Access denied.