fork download
  1. #include<stdio.h>
  2. int ATM_Transaction();
  3. int anotherTransaction, amountToWidthdraw,amountToDeposite,pin;
  4. double balance=1000;
  5.  
  6. int main()
  7.  
  8. {
  9. printf("***********Welcome to XYZ bank**********\n");
  10. printf("Enter your pin number please:\n");
  11. scanf("%d",&pin);
  12. if(pin!=1234)
  13. {
  14. printf("sorry,your pin is wrong, Pls try again with card");
  15. }
  16. else
  17. {
  18. ATM_Transaction();
  19.  
  20. }
  21. }
  22. int ATM_Transaction()
  23. {
  24. int choice;
  25. printf("\n1.Balance Enquiry \n2.cash widthdraw \n3.deposite cash \n4.Exit");
  26. scanf("%d",&choice);
  27.  
  28. switch(choice)
  29.  
  30. {
  31. case 1:
  32. printf("your bank balance is:%f",balance);
  33. printf("\n\nDo you want to perform another tansaction?\nPress 1 to proceed and 2 to exit\n\n");
  34. scanf("%d",anotherTransaction);
  35. if(anotherTransaction == 1)
  36. {
  37. ATM_Transaction();
  38. }
  39. break;
  40. case 2:
  41. printf("please Enter amount to withdraw:");
  42. scanf("%d",&amountToWidthdraw);
  43. if(amountToWidthdraw <= balance)
  44. {
  45. printf("please collect your cash\n");
  46. balance=balance-amountToWidthdraw;
  47. printf("your available balance is %lf\n",balance);
  48. printf("\n\nDo you want to perform another tansaction?\nPress 1 to proceed and 2 to exit\n\n");
  49. scanf("%d",&anotherTransaction);
  50. if(anotherTransaction==1)
  51. {
  52. ATM_Transaction();
  53.  
  54. }
  55. }
  56. else
  57. {
  58. printf("sorry in-sufficient funds in your account");
  59. printf("\n\nDo you want to perform another tansaction?\nPress 1 to proceed and 2 to exit\n\n");
  60. scanf("%d",&anotherTransaction);
  61. if(anotherTransaction == 1)
  62. {
  63. ATM_Transaction();
  64. }
  65. }
  66. break;
  67.  
  68. case 3:
  69. printf("please enter amount to deposit:");
  70. scanf("%d",&amountToDeposite);
  71. balance=amountToDeposite+balance;
  72. printf("thank you for depositing, your new blance is: %f",balance);
  73. printf("\n\nDo you want to perform another tansaction?\nPress 1 to proceed and 2 to exit\n\n");
  74. scanf("%d",&anotherTransaction);
  75. if(anotherTransaction == 1)
  76. {
  77. ATM_Transaction();
  78. }
  79. break;
  80.  
  81.  
  82. default:
  83. printf("thanks for using ATM services, See you soon");
  84.  
  85. }
  86. }
  87.  
Success #stdin #stdout 0s 4404KB
stdin
Standard input is empty
stdout
***********Welcome to XYZ bank**********
Enter your pin number please:
sorry,your pin is wrong, Pls try again with card