static void Main(string[] args) { string userOption; CheckingAccount check = new CheckingAccount(); SavingsAccount save = new SavingsAccount(); ReserveAccount reserve = new ReserveAccount(); MainMenu: Console.WriteLine("Please select a number from the list below and press enter."); List <string> clientOptions = new List <string>(); //Main Menu of options clientOptions.Add("1. View Client Information"); clientOptions.Add("2. View Account Information"); clientOptions.Add("3. Make a Deposit"); clientOptions.Add("4. Make a Withdrawal"); clientOptions.Add("5. Exit"); foreach (string option in clientOptions) { Console.WriteLine(option); } userOption = Console.ReadLine(); if (userOption == "1") { //display client information StreamReader reader = new StreamReader("ClientInfo.txt"); using (reader) { int lineNumber = 1; string line = reader.ReadLine(); while (line != null) { lineNumber++; Console.WriteLine(line); line = reader.ReadLine(); } } Console.WriteLine(); } else if (userOption == "2") //User account info { AccountBalanceMenu: Console.WriteLine("View which account balance: \n1. Checking \n2. Savings \n3. Reserve"); string accountInfoInput = Console.ReadLine(); if (accountInfoInput == "1") { check.AccountBalance(); //shows balance } else if (accountInfoInput == "2") { save.AccountBalance(); //shows balance } else if (accountInfoInput == "3") { reserve.AccountBalance(); //shows balance } else { Console.WriteLine("That is not a valid selection. Please try again."); goto AccountBalanceMenu; } } else if (userOption == "3") //Make a deposit { // AccountSelection: Console.WriteLine("Into which account: \n1. Checking \n2. Savings \n3. Reserve"); string userAccountInput = Console.ReadLine(); if (userAccountInput == "1") //Deposit -> Checking { CheckingDepositInput: Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign."); try { check.CheckingDeposit = decimal.Parse(Console.ReadLine()); check.Deposit(); //shows deposit amount and new balance and writes to text file } catch (FormatException e) { Console.WriteLine("You have entered non-numeric characters. Please try again."); goto CheckingDepositInput; } } if (userAccountInput == "2") // Deposit -> Savings { SavingsDepositInput: Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign."); try { save.SavingsDeposit = decimal.Parse(Console.ReadLine()); save.Deposit(); //shows deposit amount and new balance and writes to text file } catch (FormatException e) { Console.WriteLine("You entered non-numeric characters. Please try again."); goto SavingsDepositInput; } } if (userAccountInput == "3") //Deposit -> Reserve { ReserveDepositInput: Console.WriteLine("How much would you like to deposit? Do not enter a dollar sign."); try { reserve.ReserveDeposit = decimal.Parse(Console.ReadLine()); reserve.Deposit(); //shows deposit amount and new balance and writes to text file } catch (FormatException e) { Console.WriteLine("You have entered non-numeric characters. Please try again."); goto ReserveDepositInput; } } } // End of 3 .Make a deposit else if (userOption == "4") // Withdraw funds { // AccountSelection: Console.WriteLine("Into which account: \n1. Checking \n2. Savings \n3. Reserve"); string userAccountInputW = Console.ReadLine(); if (userAccountInputW == "1") //Withdraw -> Checking { CheckingWithdrawalInput: Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign."); try { check.CheckingWithdrawal = decimal.Parse(Console.ReadLine()); check.Withdrawal(); //show withdrawal amount and new balance and writes to text file } catch (FormatException e) { Console.WriteLine("You have entered non-numeric characters. Please try again."); goto CheckingWithdrawalInput; } } if (userAccountInputW == "2") // Withdraw -> Savings { SavingsWithdrawalInput: Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign."); try { save.SavingsWithdrawal = decimal.Parse(Console.ReadLine()); save.Withdrawal(); //shows withdrawal amount and new savings and writes to text file } catch (FormatException e) { Console.WriteLine("You have entered non-numeric characters. Please try again."); goto SavingsWithdrawalInput; } } if (userAccountInputW == "3") // Withdraw -> Reserve { ReserveWithdrawalInput: Console.WriteLine("How much would you like to withdraw? Do not enter a dollar sign."); try { reserve.ReserveWithdrawal = decimal.Parse(Console.ReadLine()); reserve.Withdrawal(); //show withdrawal amount and new balance and writes to text file } catch (FormatException e) { Console.WriteLine("You have entered non-numeric characters. Please try again."); goto ReserveWithdrawalInput; } } } else if (userOption == "5") // Exit { Environment.Exit(0); } else { Console.WriteLine("That is not a valid option. Please start over."); goto MainMenu; } goto MainMenu; } //static void main
static void Main(string[] args) { //open streamwriter to create text file StreamWriter accountReserve = new StreamWriter("ReserveAccount.txt"); StreamWriter accountSavings = new StreamWriter("SavingsAccount.txt"); StreamWriter accountChecking = new StreamWriter("CheckingAccount.txt"); //get member name Console.WriteLine("Please enter your name."); string memberName = Console.ReadLine(); Console.Clear(); //create objects to use classes SavingsAccount savings = new SavingsAccount(memberName); CheckingAccount checking = new CheckingAccount(memberName); ReserveAccount reserve = new ReserveAccount(memberName); //streamwriter .txt files accountChecking.WriteLine("Gringott's Member " + memberName); accountChecking.WriteLine("Account Number: " + checking.AccountNumber); accountChecking.WriteLine("Account Type: Checking Account"); accountChecking.WriteLine("Account Balance: " + checking.AccountBalance); accountSavings.WriteLine("Gringott's Member " + memberName); accountSavings.WriteLine("Account Number: " + savings.AccountNumber); accountSavings.WriteLine("Account Type: Savings Account"); accountSavings.WriteLine("Account Balance: " + savings.AccountBalance); accountReserve.WriteLine("Gringott's Member " + memberName); accountReserve.WriteLine("Account Number: " + reserve.AccountNumber); accountReserve.WriteLine("Account Type: Reserve Account"); accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance); //loop for menu while (true) { //menu Console.WriteLine("Welcome to Gringott's Bank for Wizards and Witches. Please make a selection."); Console.WriteLine("1: View Member Info"); Console.WriteLine("View Account Balance of:" + memberName); Console.WriteLine("\t2: Checking Account"); Console.WriteLine("\t3: Savings Account"); Console.WriteLine("\t4: Reserve Account"); Console.WriteLine("5: Deposit Funds"); Console.WriteLine("6: Withdrawal Funds"); //member choice for which action on menu int action = int.Parse(Console.ReadLine()); Console.Clear(); //switch/case actions switch (action) { case 1: savings.ClientInfo(); break; case 2: checking.ViewAccountBalance(); break; case 3: savings.ViewAccountBalance(); break; case 4: reserve.ViewAccountBalance(); break; case 5: Console.WriteLine("Please make a selection."); Console.WriteLine("1: Checking Account"); Console.WriteLine("2: Savings Account"); Console.WriteLine("3: Reserve Account"); int choice = int.Parse(Console.ReadLine()); Console.WriteLine("Enter deposit amount."); int deposit = int.Parse(Console.ReadLine()); // switch/case for deposit selection switch (choice) { case 1: checking.Deposit(deposit); Console.WriteLine("Your account balance is " + checking.AccountBalance); accountChecking.WriteLine("+ " + deposit + " " + DateTime.Now); accountChecking.WriteLine("Account Balance: " + checking.AccountBalance); break; case 2: savings.Deposit(deposit); Console.WriteLine("Your account balance is " + savings.AccountBalance); accountSavings.WriteLine("+ " + deposit + " " + DateTime.Now); accountSavings.WriteLine("Account Balance: " + savings.AccountBalance); break; case 3: reserve.Deposit(deposit); Console.WriteLine("Your account balance is " + reserve.AccountBalance); accountReserve.WriteLine("+ " + deposit + " " + DateTime.Now); accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance); break; default: break; } break; case 6: Console.WriteLine("Please make a selection."); Console.WriteLine("1: Checking Account"); Console.WriteLine("2: Savings Account"); Console.WriteLine("3: Reserve Account"); int pick = int.Parse(Console.ReadLine()); Console.WriteLine("Enter withdrawal amount."); int withdrawal = int.Parse(Console.ReadLine()); //switch/case for withdrawing switch (pick) { case 1: checking.Withdrawal(withdrawal); Console.WriteLine("The new balance is " + checking.AccountBalance); accountChecking.WriteLine("- " + withdrawal + " " + DateTime.Now); accountChecking.WriteLine("Account Balance: " + checking.AccountBalance); break; case 2: savings.Withdrawal(withdrawal); Console.WriteLine("The new balance is " + savings.AccountBalance); accountSavings.WriteLine("- " + withdrawal + " " + DateTime.Now); accountSavings.WriteLine("Account Balance: " + savings.AccountBalance); break; case 3: reserve.Withdrawal(withdrawal); Console.WriteLine("The new balance is " + reserve.AccountBalance); accountReserve.WriteLine("- " + withdrawal + " " + DateTime.Now); accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance); break; } break; default: //quits break; } Console.WriteLine("Do you need more time?"); string yesOrNo = Console.ReadLine(); if (yesOrNo.ToLower() == "y") { Console.Clear(); } else { //quits the program if "no" Console.Clear(); break; } } //closes the streamwriters accountReserve.Close(); accountSavings.Close(); accountChecking.Close(); Quit(); }