Advertisement
Guest User

Untitled

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