Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.01 KB | None | 0 0
  1. namespace CSF1Homework
  2. {
  3. class ATM
  4. {
  5. static void Main(string[] args)
  6. {
  7. Console.WriteLine("Hello, and welcome to UMB Bank!");
  8. Console.Title = "UMB Bank ATM Machine";
  9.  
  10. //use while loop
  11. int retryCount = 5;
  12. if (retryCount == 0)
  13. {
  14. Console.WriteLine("You have been locked out of the ATM.");
  15. }//end if
  16.  
  17. else
  18. {
  19.  
  20.  
  21. start: //use for loop
  22.  
  23. Console.Write("Please enter your 7-digit account number: ");
  24. int accountNumber = Convert.ToInt32(Console.ReadLine());
  25.  
  26. decimal accountBalance = 1000.00m;
  27.  
  28. if (accountNumber == 1234567)
  29. {
  30. restartPin://use for loop
  31. Console.WriteLine("Hello, Devon, welcome to your account page!");
  32. Console.Write("For security purposes, please enter in your 4-digit pin: ");
  33. int pinNumber = Convert.ToInt32(Console.ReadLine());
  34.  
  35. if (pinNumber == 1234)
  36. {
  37. restartChoices:
  38. Console.WriteLine("You have been granted access to your account! ");
  39.  
  40. Console.WriteLine("Choose an option: \n1) Deposits\n2) Withdraws\n3) Balance Inquiry\n4) Exit");
  41. string userChoice = Console.ReadLine().ToLower();
  42. switch (userChoice)
  43. {
  44. case "1":
  45. case "deposits":
  46. case "d":
  47. Console.WriteLine("Your account currently has {0:c}.", accountBalance);
  48. Console.WriteLine("How much money would you like to deposit to your account? $:");
  49. decimal depositAmount = Convert.ToDecimal(Console.ReadLine());
  50. accountBalance = accountBalance + depositAmount;
  51. Console.WriteLine("You have successfully added {0:c} to your account. Your new account balance is {1:c}.", depositAmount, accountBalance);
  52. Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
  53. string userMainMenuDeposits = Console.ReadLine().ToLower();
  54. if (userMainMenuDeposits == "y" || userMainMenuDeposits == "yes")
  55. {
  56.  
  57. }//end if
  58.  
  59. else
  60. {
  61. goto restartLogout;
  62. }//end else
  63.  
  64. break;
  65. case "2":
  66. case "withdraws":
  67. case "w":
  68. Console.WriteLine("Your account currently has {0:c}.", accountBalance);
  69. Console.WriteLine("How much money would you like to withdraw from your account? $:");
  70. decimal withdrawAmount = Convert.ToDecimal(Console.ReadLine());
  71. Console.WriteLine("You have successfully withdrawn {0:c} from your account. Your new account balance is {1:c}.", withdrawAmount, accountBalance);
  72. Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
  73. string userMainMenuWithdraws = Console.ReadLine().ToLower();
  74. if (userMainMenuWithdraws == "y" || userMainMenuWithdraws == "yes")
  75. {
  76. goto restartChoices;
  77. }//end if
  78.  
  79. else
  80. {
  81. goto restartLogout;
  82. }//end else
  83. break;
  84.  
  85. case "3":
  86. case "balance inquiry":
  87. case "b":
  88. Console.WriteLine("Your account currently has {0:c}.", accountBalance);
  89. Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
  90. string userMainMenuBalance = Console.ReadLine().ToLower();
  91. if (userMainMenuBalance == "y" || userMainMenuBalance == "yes")
  92. {
  93. goto restartChoices;
  94. }//end if
  95.  
  96. else
  97. {
  98. goto restartLogout;
  99. }//end else
  100. break;
  101. case "4":
  102. case "exit":
  103. case "e":
  104. restartLogout:
  105. Console.WriteLine("Please enter your account PIN to sign out of the ATM");
  106. int pinNumber2 = Convert.ToInt32(Console.ReadLine());
  107. if (pinNumber2 == 1234)
  108. {
  109. Console.WriteLine("You have been successfully signed out of your account. Do not forget to remove your card");
  110. }//end if
  111. else
  112. {
  113. Console.WriteLine("Invalid PIN number. Please try again.");
  114. goto restartLogout;
  115.  
  116. }//end else
  117. break;
  118. default:
  119. Console.WriteLine("Invalid user choice. Please select from the menu above.");
  120. goto restartChoices;
  121. break;
  122. }
  123. }//end if
  124.  
  125. else
  126. {
  127. Console.WriteLine("You have entered the incorrect pin. Please try again. ");
  128. goto restartPin;
  129. }//end else
  130.  
  131. }//end if
  132.  
  133. else
  134. {
  135. if (retryCount > 0)
  136. {
  137. while (retryCount >0)
  138. {
  139. //retryCount -= 1;
  140. //Console.WriteLine("You have failed a login attempt. You have {0} attemps remaining.", retryCount);
  141. }//end while
  142. }//end if
  143. }//end else
  144.  
  145.  
  146. }//end else
  147. }//end else
  148. }//end Main()
  149. }//end class
  150. //end namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement