Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CSF1Homework
- {
- class ATM
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Hello, and welcome to UMB Bank!");
- Console.Title = "UMB Bank ATM Machine";
- //use while loop
- int retryCount = 5;
- if (retryCount == 0)
- {
- Console.WriteLine("You have been locked out of the ATM.");
- }//end if
- else
- {
- start: //use for loop
- Console.Write("Please enter your 7-digit account number: ");
- int accountNumber = Convert.ToInt32(Console.ReadLine());
- decimal accountBalance = 1000.00m;
- if (accountNumber == 1234567)
- {
- restartPin://use for loop
- Console.WriteLine("Hello, Devon, welcome to your account page!");
- Console.Write("For security purposes, please enter in your 4-digit pin: ");
- int pinNumber = Convert.ToInt32(Console.ReadLine());
- if (pinNumber == 1234)
- {
- restartChoices:
- Console.WriteLine("You have been granted access to your account! ");
- Console.WriteLine("Choose an option: \n1) Deposits\n2) Withdraws\n3) Balance Inquiry\n4) Exit");
- string userChoice = Console.ReadLine().ToLower();
- switch (userChoice)
- {
- case "1":
- case "deposits":
- case "d":
- Console.WriteLine("Your account currently has {0:c}.", accountBalance);
- Console.WriteLine("How much money would you like to deposit to your account? $:");
- decimal depositAmount = Convert.ToDecimal(Console.ReadLine());
- accountBalance = accountBalance + depositAmount;
- Console.WriteLine("You have successfully added {0:c} to your account. Your new account balance is {1:c}.", depositAmount, accountBalance);
- Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
- string userMainMenuDeposits = Console.ReadLine().ToLower();
- if (userMainMenuDeposits == "y" || userMainMenuDeposits == "yes")
- {
- }//end if
- else
- {
- goto restartLogout;
- }//end else
- break;
- case "2":
- case "withdraws":
- case "w":
- Console.WriteLine("Your account currently has {0:c}.", accountBalance);
- Console.WriteLine("How much money would you like to withdraw from your account? $:");
- decimal withdrawAmount = Convert.ToDecimal(Console.ReadLine());
- Console.WriteLine("You have successfully withdrawn {0:c} from your account. Your new account balance is {1:c}.", withdrawAmount, accountBalance);
- Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
- string userMainMenuWithdraws = Console.ReadLine().ToLower();
- if (userMainMenuWithdraws == "y" || userMainMenuWithdraws == "yes")
- {
- goto restartChoices;
- }//end if
- else
- {
- goto restartLogout;
- }//end else
- break;
- case "3":
- case "balance inquiry":
- case "b":
- Console.WriteLine("Your account currently has {0:c}.", accountBalance);
- Console.WriteLine("Would you like to go back to the main menu?: Y/N: ");
- string userMainMenuBalance = Console.ReadLine().ToLower();
- if (userMainMenuBalance == "y" || userMainMenuBalance == "yes")
- {
- goto restartChoices;
- }//end if
- else
- {
- goto restartLogout;
- }//end else
- break;
- case "4":
- case "exit":
- case "e":
- restartLogout:
- Console.WriteLine("Please enter your account PIN to sign out of the ATM");
- int pinNumber2 = Convert.ToInt32(Console.ReadLine());
- if (pinNumber2 == 1234)
- {
- Console.WriteLine("You have been successfully signed out of your account. Do not forget to remove your card");
- }//end if
- else
- {
- Console.WriteLine("Invalid PIN number. Please try again.");
- goto restartLogout;
- }//end else
- break;
- default:
- Console.WriteLine("Invalid user choice. Please select from the menu above.");
- goto restartChoices;
- break;
- }
- }//end if
- else
- {
- Console.WriteLine("You have entered the incorrect pin. Please try again. ");
- goto restartPin;
- }//end else
- }//end if
- else
- {
- if (retryCount > 0)
- {
- while (retryCount >0)
- {
- //retryCount -= 1;
- //Console.WriteLine("You have failed a login attempt. You have {0} attemps remaining.", retryCount);
- }//end while
- }//end if
- }//end else
- }//end else
- }//end else
- }//end Main()
- }//end class
- //end namespace
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement