static void Main(string[] args) { start: //redirect from password being incorrect Accounts account1 = new Accounts(); //instantiated each child-class CheckingAccount check1 = new CheckingAccount(); ReserveAccount reserve1 = new ReserveAccount(); SavingsAccount savings1 = new SavingsAccount(); Console.WriteLine("Thank you for visiting The First National Bank of Andy! \nDo you have an account with us?"); string existingCustomer = Console.ReadLine(); //I have a save option to bring back previous account info if (existingCustomer.ToUpper() == "Y" || existingCustomer.ToUpper() == "YES") { Console.Clear(); StreamReader retrieveSave = new StreamReader("..\\..\\BankLogin.txt"); //another input of "enter" to continue. int numberOfLines = 12; string[] lineArray = new string[numberOfLines]; //taking BankLogin.txt and turning lines into an array to read them for (int i = 1; i < numberOfLines; i++) { lineArray[i] = retrieveSave.ReadLine(); } account1.FirstName = (lineArray[1]); //these are using the properties to change the variable amounts and string name account1.LastName = (lineArray[2]); account1.UserName = (lineArray[3]); account1.PassWord = (lineArray[4]); account1.ClientNumber = int.Parse(lineArray[5]); //all lines read as a string, so Parse will get them into an int or double check1.CheckBalance = double.Parse(lineArray[6]); check1.CheckingAccountNumber = int.Parse(lineArray[7]); reserve1.ReserveBalance = double.Parse(lineArray[8]); reserve1.ReserveAccountNumber = int.Parse(lineArray[9]); savings1.SavingsBalance = double.Parse(lineArray[10]); savings1.SavingsAccountNumber = int.Parse(lineArray[11]); retrieveSave.Close(); check1.FirstName = account1.FirstName; //this is getting all the info from the base class accounts reserve1.FirstName = account1.FirstName; //into the sub-class accounts savings1.FirstName = account1.FirstName; check1.LastName = account1.LastName; reserve1.LastName = account1.LastName; savings1.LastName = account1.LastName; check1.ClientNumber = account1.ClientNumber; reserve1.ClientNumber = account1.ClientNumber; savings1.ClientNumber = account1.ClientNumber; Console.WriteLine(account1.UserName + " please enter your password."); //password was set with streamwriter previously string loginAttempt = Console.ReadLine(); if (loginAttempt.ToUpper() == account1.PassWord.ToUpper()) //uppercase or lowercase won't matter in password { Console.WriteLine("Welcome back " + account1.FirstName + "!"); goto mainmenu; //this sends it to the main menu } else { Console.WriteLine("Your password attempt is incorrect. You will be redirected to the start."); goto start; } } else //this else is for those who don't have a login and password { //creating a new profile Console.Clear(); Console.WriteLine("Let\'s set you up a new account!\nWhat is your first name?"); account1.FirstName = Console.ReadLine(); check1.FirstName = account1.FirstName; reserve1.FirstName = account1.FirstName; savings1.FirstName = account1.FirstName; Console.WriteLine("Thank you, " + account1.FirstName + ". What is your last name?"); account1.LastName = Console.ReadLine(); check1.LastName = account1.LastName; reserve1.LastName = account1.LastName; savings1.LastName = account1.LastName; Console.WriteLine("Please enter a username you would like to use."); account1.UserName = Console.ReadLine(); Console.WriteLine("Please enter a password. Please remember this password to login in the future."); account1.PassWord = Console.ReadLine(); account1.GenerateClientNumber(); check1.ClientNumber = account1.ClientNumber; reserve1.ClientNumber = account1.ClientNumber; savings1.ClientNumber = account1.ClientNumber; Console.WriteLine(account1.FirstName + ", your client ID number is " + account1.ClientNumber); Console.WriteLine("Here at FNB of Andy, we require all customers to open 3 accounts\nA Checking Account, a Reserve Account, and a Savings Account."); System.Threading.Thread.Sleep(5500); //this gives some time for the above lines to be read. Next method to be called clears all lines check1.GenerateCheckingAccount(); //these next 6 lines call to the inherited methods for initial deposits and account numbers check1.Deposit(); reserve1.GenerateReserveAccount(); reserve1.Deposit(); savings1.GenerateSavingsAccount(); savings1.Deposit(); } //main menu mainmenu: Console.WriteLine("\n" + account1.FirstName + ", please select the account you wish to view or exit."); Console.WriteLine("You may make a deposit, withdrawal, or view account balance in\nthe account you select."); Console.WriteLine("Select 1 to view Checking Account."); Console.WriteLine("Select 2 to view Reserve Account."); Console.WriteLine("Select 3 to view Savings Account."); Console.WriteLine("Select 4 to Exit and receive your receipt."); int selection = int.Parse(Console.ReadLine()); if (selection == 1) //if/else if for the 4 options. Selection 1 brings us to checking options { Console.Clear(); //console.clear is used to make console more readable Console.WriteLine("Checking Account Options:"); Console.WriteLine("Select 1 to make a deposit."); Console.WriteLine("Select 2 to make a withdrawal."); Console.WriteLine("Select 3 to check balance."); Console.WriteLine("Select 4 to return to the main menu."); int checkMenu = int.Parse(Console.ReadLine()); if (checkMenu == 1) { check1.Deposit(); } else if (checkMenu == 2) { check1.Withdraw(); } else if (checkMenu == 3) { Console.Clear(); Console.WriteLine(check1.FirstName + ", your current checking balance is $" + check1.CheckBalance + "."); } else { Console.Clear(); goto mainmenu; //takes us back to the main menu } } else if (selection == 2) //selection 2 brings us to reserve account options { Console.Clear(); Console.WriteLine("Reserve Account Options:"); Console.WriteLine("Select 1 to make a deposit."); Console.WriteLine("Select 2 to make a withdrawal."); Console.WriteLine("Select 3 to check balance."); Console.WriteLine("Select 4 to return to the main menu."); int resMenu = int.Parse(Console.ReadLine()); if (resMenu == 1) //nested if/else if to call upon particular inherited method { reserve1.Deposit(); } else if (resMenu == 2) { reserve1.Withdraw(); } else if (resMenu == 3) { Console.Clear(); Console.WriteLine(check1.FirstName + ", your current reserve balance is $" + reserve1.ReserveBalance + "."); } else { Console.Clear(); goto mainmenu; } } else if (selection == 3) //selection 3 brings us to savings account options { Console.Clear(); Console.WriteLine("Savings Account Options:"); Console.WriteLine("Select 1 to make a deposit."); Console.WriteLine("Select 2 to make a withdrawal."); Console.WriteLine("Select 3 to check balance."); Console.WriteLine("Select 4 to return to the main menu."); int savMenu = int.Parse(Console.ReadLine()); if (savMenu == 1) { savings1.Deposit(); } else if (savMenu == 2) { savings1.Withdraw(); } else if (savMenu == 3) { Console.Clear(); Console.WriteLine(check1.FirstName + ", your current savings balance is $" + savings1.SavingsBalance + "."); } else { Console.Clear(); goto mainmenu; } } else { Console.Clear(); Console.WriteLine("Thank you for banking with FNB of Andy. Have a great day!"); StreamWriter bankLogin = new StreamWriter("..\\..\\BankLogin.txt"); //this will write or overwrite the txt using (bankLogin) //that will be used to read when console is { //reopened and saved bank info is selected. bankLogin.WriteLine(account1.FirstName); bankLogin.WriteLine(account1.LastName); bankLogin.WriteLine(account1.UserName); bankLogin.WriteLine(account1.PassWord); bankLogin.WriteLine(account1.ClientNumber); bankLogin.WriteLine(check1.CheckBalance); bankLogin.WriteLine(check1.CheckingAccountNumber); bankLogin.WriteLine(reserve1.ReserveBalance); bankLogin.WriteLine(reserve1.ReserveAccountNumber); bankLogin.WriteLine(savings1.SavingsBalance); bankLogin.WriteLine(savings1.SavingsAccountNumber); } Environment.Exit(0); } goto mainmenu; //if user did not exit, this will send back to main menu }
static void Main(string[] args) { //Account 1 CheckingAccount account1Checking = new CheckingAccount(); ReserveAccount account1Res = new ReserveAccount(); SavingAccount account1Saving = new SavingAccount(); Account Greeting = new Account(); StreamWriter Sam = new StreamWriter("Sam.txt"); StreamWriter Withdraw = new StreamWriter("Withdraw.txt"); StreamWriter Deposit = new StreamWriter("Deposit.txt"); //Intro Console.WriteLine("\n\n"); Console.WriteLine("Hello, welcome to the automated bank teller!\nWhich account are you accessing today?"); Console.WriteLine("Sam S.?"); string choosenOne = Console.ReadLine(); using (Sam) { Sam.WriteLine("user name: " + choosenOne); do { if (choosenOne.ToLower() == "sam s." || choosenOne.ToLower() == "sam s" || choosenOne.ToLower() == "sam") { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Please enter your 7 digit account number."); string userAccountNum = Console.ReadLine(); Sam.WriteLine("user account #: " + userAccountNum); if (userAccountNum.Length > 7 || userAccountNum.Length < 7) { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Please enter the your 7 digit account number."); userAccountNum = Console.ReadLine(); } Console.WriteLine("Please enter your password."); string password = Console.ReadLine(); if (password == "password1") { break; } else { Console.WriteLine("That's the wrong password, please enter it again."); password = Console.ReadLine(); } } else { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Hello, welcome to the automated bank teller!\nWhich account are you accessing today?"); Console.WriteLine("That account does not exist in this program."); choosenOne = Console.ReadLine(); } } while (choosenOne.ToLower() == "sam s." || choosenOne.ToLower() == "sam s" || choosenOne.ToLower() == "sam"); } //Account 1 if (choosenOne.ToLower() == "sam s." || choosenOne.ToLower() == "sam s" || choosenOne.ToLower() == "sam") { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Welcome back Sam S., here is your account information."); account1Checking.DisplayCheckingAccount(); account1Res.DisplayResAccount(); account1Saving.DisplaySavingAccount(); Console.WriteLine("Would you like to withdraw or deposit today? Or \"quit\" to quit."); string choosenWithDepo = Console.ReadLine(); //withdraw if (choosenWithDepo.ToLower() == "withdraw") { Console.Clear(); Console.WriteLine("\n\n"); account1Checking.DisplayCheckingAccount(); account1Res.DisplayResAccount(); account1Saving.DisplaySavingAccount(); Console.WriteLine(); Greeting.WithdrawDisplay(); string choosenAccount = Console.ReadLine(); ; do { using (Withdraw) { Withdraw.WriteLine(choosenAccount); } //} if (choosenAccount.ToLower() == "checkings") { Console.WriteLine("How much would you like to withdraw from your checking accout?"); Console.Write("$"); double userNumChecking = double.Parse(Console.ReadLine()); account1Checking.SubUserChecking(userNumChecking); Withdraw.WriteLine("-$" + userNumChecking + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); } else if (choosenAccount.ToLower() == "reserved") { Console.WriteLine("How much would you like to withdraw from your reserved accout?"); Console.Write("$"); double userNumRes = double.Parse(Console.ReadLine()); account1Res.SubUserRes(userNumRes); Withdraw.WriteLine("-$" + userNumRes + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); } else if (choosenAccount.ToLower() == "savings") { Console.WriteLine("How much would you like to withdraw from your checking accout?"); Console.Write("$"); double userNumSaving = double.Parse(Console.ReadLine()); account1Saving.SubUserSaving(userNumSaving); Withdraw.WriteLine("-$" + userNumSaving + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); } else if (choosenAccount.ToLower() == "quit") { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Thank you for stopping by!"); Environment.Exit(0); } else { Console.Clear(); Console.WriteLine("\n\n"); account1Checking.DisplayCheckingAccount(); account1Res.DisplayResAccount(); account1Saving.DisplaySavingAccount(); Console.WriteLine(); Greeting.WithdrawDisplay(); Console.WriteLine("That wasn't an options, please pick again from the list"); choosenAccount = Console.ReadLine(); } } while (choosenAccount != ""); } //deposit else if (choosenWithDepo.ToLower() == "deposit") { Console.Clear(); Console.WriteLine("\n\n"); account1Checking.DisplayCheckingAccount(); account1Res.DisplayResAccount(); account1Saving.DisplaySavingAccount(); Console.WriteLine(); Console.WriteLine("Which account would like to deposit to?\nCheckings, Resereved, or Savings account? Enter \"quit\" to exit."); string choosenAccount = Console.ReadLine(); do { using (Deposit) { Deposit.WriteLine(choosenWithDepo); } if (choosenAccount.ToLower() == "checkings") { Console.WriteLine("How much would you like to deposit from your checking accout?"); Console.Write("$"); double userNumChecking = double.Parse(Console.ReadLine()); account1Checking.AddUserChecking(userNumChecking); Deposit.WriteLine("+$" + userNumChecking + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); Console.ReadLine(); } else if (choosenAccount.ToLower() == "reserved") { Console.WriteLine("How much would you like to deposit from your reserved accout?"); Console.Write("$"); double userNumRes = double.Parse(Console.ReadLine()); account1Res.AddUserRes(userNumRes); Deposit.WriteLine("+$" + userNumRes + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); Console.ReadLine(); } else if (choosenAccount.ToLower() == "savings") { Console.WriteLine("How much would you like to deposit from your savings accout?"); Console.Write("$"); double userNumSavings = double.Parse(Console.ReadLine()); account1Saving.AddUserSaving(userNumSavings); Deposit.WriteLine("+$" + userNumSavings + DateTime.Now.ToString("yyyy.MM.dd hh:mm:ss")); Console.ReadLine(); } else if (choosenAccount.ToLower() == "quit") { Console.Clear(); Console.WriteLine("\n\n"); Console.WriteLine("Thank you for stopping by!"); Environment.Exit(0); break; } else { Console.Clear(); Console.WriteLine("\n\n"); account1Checking.DisplayCheckingAccount(); account1Res.DisplayResAccount(); account1Saving.DisplaySavingAccount(); Console.WriteLine(); Console.WriteLine("Which account would like to deposit to?\nCheckings, Resereved, or Savings account? Enter \"quit\" to exit."); Console.WriteLine("That wasn't an options, please pick again from the list"); choosenAccount = Console.ReadLine(); } } while (choosenAccount != ""); } else if (choosenWithDepo.ToLower() == "quit") { Console.WriteLine("Thank you for using this program."); Environment.Exit(0); } } }
static void Main(string[] args) { //This is the Bank Account Project work for the We Can Code It Bootcamp //Robert Horrocks, August 4, 2016 //You will be designing a console application to manage a client’s bank account. //For now, the application will have only one client that is hard-coded into the system. //Tasks: //Using a user facing interface, it will pull information and display //Menu Items: //View Client Information //View Account Balance //Checking Account Balance //Reserve Account Balance //Savings Account Balance //Deposit Funds //Withdraw Funds //Exit //Checking Account Class // Inherits Account base class // Minimum 2 fields // Minimum 2 properties // Minimum 1 constructor //Reserve Account Class // Inherits Account base class // Minimum 2 fields // Minimum 2 properties // Minimum 1 constructor //Savings Account Class // Inherits Account base class // Minimum 2 fields // Minimum 2 properties // Minimum 1 constructor //Objects // Minimum 1 object instantiated from the Checking Account Class // Minimum 1 object instantiated from the Reserve Account Class // Minimum 1 object instantiated from the Savings Account Class //Other Requirements // Use StreamWriter to create account summary files that track transactions //for each account type (each type has its own text file). //Files should be located in the Debug Folder and should include: // Name of Client // Client Account Number // Account Type(Checking, Reserve, or Savings) // Each transaction should be on its own line // Each transaction should show date and time of transaction(must use DateTime Class) // Each transaction should show a “+” for deposit and a “-” for withdrawal // Each transaction should show the transaction amount // Each transaction should show the new current balance after the transaction double totalBalance = 0.0d; double checkingBalance = 0.0d; double reserveBalance = 0.0d; double savingsBalance = 0.0d; totalBalance = (checkingBalance + reserveBalance + savingsBalance); string clientInput = "0"; Account joeSmith = new Account(); CheckingAccount checkingUser = new CheckingAccount(); StringBuilder mainMenu = new StringBuilder(); mainMenu.Append("OurBank Main Menu\n"); mainMenu.Append("View Client Information, Press '1'\n"); mainMenu.Append("View Account Balance Information, Press '2'\n"); mainMenu.Append("To Deposit Funds, Press '3'\n"); mainMenu.Append("To Withdraw Funds, Press '4'\n"); mainMenu.Append("To Exit the Application, Press '5'\n"); mainMenu.Append("Thank you for being a valued OurBank customer!\n"); mainMenu.Append("Today's Date and time is: " + DateTime.Now + "\n"); Console.WriteLine(mainMenu.ToString()); clientInput = Console.ReadLine(); if (clientInput == "1") { joeSmith.PrintClientInfo(); } else if (clientInput == "2") { joeSmith.PrintStats(); } else if (clientInput == "3") { joeSmith.PrintStats(); joeSmith.Deposit(); } else if (clientInput == "4") { Console.Clear(); Console.WriteLine("Do you want to write a check (1), or withdrawl from savings (2)?"); int userResponse = Convert.ToInt32(Console.ReadLine()); if (userResponse == 1) { checkingUser.WriteCheck(); } else { joeSmith.Withdrawl(); } } Console.ReadKey(); StreamWriter checkingWriter = new StreamWriter("checking.txt"); using (checkingWriter){ checkingWriter.Write("Hekki Wirld"); } StreamWriter savingsWriter = new StreamWriter("savings.txt"); using (savingsWriter) { savingsWriter.Write(DateTime.Now); } StreamWriter reserveWriter = new StreamWriter("reserve.txt"); using (reserveWriter) { reserveWriter.Write(DateTime.Now); } }
static void Main(string[] args) { //instantiate below Client client2 = new Client(clientName, clientPhoneNumber, clientAddress, clientRepresentative); CheckingAccount checking1 = new CheckingAccount(); SavingsAccount savings1 = new SavingsAccount(); do { Console.WriteLine("Select the number of your choice: "); Console.WriteLine("1: View Client Information"); Console.WriteLine("2: View Account Balances"); Console.WriteLine("3: Deposit Funds"); Console.WriteLine("4: Withdraw Funds"); Console.WriteLine("5: Quit"); var userChoice = Console.ReadLine(); Console.WriteLine(); if (!Int32.TryParse(userChoice, out num)) { continue; } if (userChoice == "5") { Environment.Exit(0); } Console.WriteLine("Choice = " + userChoice); if (userChoice == "1") { client2.ClientWork(); Console.WriteLine(); } else if (userChoice == "2") { Console.WriteLine("1 - Checking Balance"); Console.WriteLine("2 - Savings Balance"); int accountSelection = int.Parse(Console.ReadLine()); if (accountSelection == 1) { checking1.CheckBalance(); Console.WriteLine(); } else if (accountSelection == 2) { savings1.CheckBalance(); Console.WriteLine(); } } else if (userChoice == "3") { Console.WriteLine("1 - Checking Deposit"); Console.WriteLine("2 - Savings Deposit"); int withdrawalSelection = int.Parse(Console.ReadLine()); if (withdrawalSelection == 1) { checking1.AccountDeposit(); Console.WriteLine(); } else if (withdrawalSelection == 2) { savings1.AccountDeposit(); Console.WriteLine(); } } else if (userChoice == "4") { Console.WriteLine("1 - Checking Withdrawal"); Console.WriteLine("2 - Savings Withdrawal"); int withdrawalSelection = int.Parse(Console.ReadLine()); if (withdrawalSelection == 1) { checking1.AccountWithdrawal(); Console.WriteLine(); } else if (withdrawalSelection == 2) { savings1.AccountWithdrawal(); Console.WriteLine(); } } } while (true); }
static void Main(string[] args) { int userInput; ClientInformation userclientInformation = new ClientInformation(); Accounts userAccounts = new Accounts(); CheckingAccount userCheckingAccount = new CheckingAccount(); SavingsAccount userSavingsAccount = new SavingsAccount(); string balance = " "; string deposit = " "; string withdraw = " "; do { Console.WriteLine(""); Console.WriteLine("Welcome to the Corgi Banking Application."); Console.WriteLine("What would you like to do?"); Console.WriteLine("Type 1 to view client information."); Console.WriteLine("Type 2 to view account balance."); Console.WriteLine("Type 3 to deposit funds."); Console.WriteLine("Type 4 to withdraw funds."); Console.WriteLine("Type 5 to exit program"); Console.WriteLine(""); userInput = int.Parse(Console.ReadLine()); switch (userInput) { case 1: //// declare client information Console.WriteLine("Client Information:"); Console.WriteLine(userclientInformation.ClientName); Console.WriteLine(userclientInformation.ClientAddress); Console.WriteLine(userclientInformation.ClientEmailAddress); Console.WriteLine(""); break; case 2: //// View Balances Console.WriteLine("Type \"a\" to review checking account balance."); Console.WriteLine(""); Console.WriteLine("Type \"b\" to review savings account balance."); Console.WriteLine(""); balance = Console.ReadLine(); balance = balance.ToLower(); if (balance == "a") { userCheckingAccount.CheckingAccountNumber(); userCheckingAccount.CheckingBalance(); Console.WriteLine(""); } if (balance == "b") { userSavingsAccount.SavingsAccountNumber(); userSavingsAccount.SavingsBalance(); Console.Write(""); } break; case 3: //// to deposit funds and get balances Console.WriteLine("Type \"c\" to deposit funds into checking account."); Console.WriteLine(""); Console.WriteLine("Type \"d\" to deposit funds into savings account."); deposit = Console.ReadLine(); deposit = deposit.ToLower(); if (deposit == "c") { userCheckingAccount.BalanceAfterDeposit(); } if (deposit == "d") { userSavingsAccount.BalanceAfterDeposit(); } break; case 4: //// to withdraw funds and get balances Console.WriteLine("Type \"e\" to withdraw funds from checking account."); Console.WriteLine(""); Console.WriteLine("Type \"f\" to withdraw funds from savings account."); Console.WriteLine(""); withdraw = Console.ReadLine(); withdraw = withdraw.ToLower(); if (withdraw == "e") { userCheckingAccount.BalanceAfterWithdraw(); } if (withdraw == "f") { userSavingsAccount.BalanceAfterWithdraw(); } break; case 5: // to exit break; } } while (userInput != 5); Console.Write(""); Console.WriteLine("Thank you for using Corgi Banking. Have a nice day."); Console.WriteLine(""); }
static void Main(string[] args) { //Must instantiate one client object //Must instantiate one checking account object //Must instantiate one savings account object //All menu options listed above must have functionality behind them //Program should run until user selects 'Exit' //SWITCH CASE?? Client firstClient = new Client(); CheckingAccount firstChecking = new CheckingAccount(129304, 567.80m); SavingsAccount firstSavings = new SavingsAccount(129305, 100.00m, 10.00m); Console.WriteLine("Hello, {0}! Please select an option.", firstClient.FirstName); Console.WriteLine(); bool isUsing = true; while (isUsing == true) { Console.WriteLine("Please select an option:"); ShowOptions(); int userChoice = int.Parse(Console.ReadLine()); switch (userChoice) { case 1: { Console.WriteLine("Name: {0} {1}", firstClient.FirstName, firstClient.LastName); Console.WriteLine("Age: {0}", firstClient.Age); Console.WriteLine(); break; } case 2: { Console.WriteLine(); bool choseOption = true; while (choseOption == true) { Console.WriteLine("Which account would you like to view the balance of?"); Console.WriteLine("a. Checking Account"); Console.WriteLine("b. Savings Account"); string accountChoice = Console.ReadLine(); Console.WriteLine(); if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("Your checking account balance is ${0}", firstChecking.AccountBalance); choseOption = false; } else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("Your savings account balance is ${0}", firstSavings.AccountBalance); choseOption = false; } else { Console.WriteLine("Please select 'a' or 'b'."); } Console.WriteLine(); } break; } case 3: { Console.WriteLine(); Console.WriteLine("How much would you like to deposit? Please do not include \"$\" or \",\""); decimal depositAmount = decimal.Parse(Console.ReadLine()); bool choseOption = true; while (choseOption == true) { Console.WriteLine("Which account would you like to deposit into?"); Console.WriteLine("a. Checking Account"); Console.WriteLine("b. Savings Account"); string accountChoice = Console.ReadLine(); Console.WriteLine(); if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase)) { firstChecking.Deposit(depositAmount); Console.WriteLine("Your checking account balance is now ${0}", firstChecking.AccountBalance); choseOption = false; } else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase)) { firstSavings.Deposit(depositAmount); Console.WriteLine("Your savings account balance is now ${0}", firstSavings.AccountBalance); choseOption = false; } else { Console.WriteLine("Please select 'a' or 'b'."); } Console.WriteLine(); } break; } case 4: { Console.WriteLine(); Console.WriteLine("How much would you like to withdraw? Please do not include \"$\" or \",\""); decimal withdrawAmount = decimal.Parse(Console.ReadLine()); bool choseOption = true; while (choseOption == true) { Console.WriteLine("Which account would you like to withdraw from?"); Console.WriteLine("a. Checking Account"); Console.WriteLine("b. Savings Account"); string accountChoice = Console.ReadLine(); Console.WriteLine(); if (accountChoice.Equals("a", StringComparison.CurrentCultureIgnoreCase)) { firstChecking.Withdraw(withdrawAmount); Console.WriteLine("Your checking account balance is now ${0}.", firstChecking.AccountBalance); choseOption = false; } else if (accountChoice.Equals("b", StringComparison.CurrentCultureIgnoreCase)) { firstSavings.Withdraw(withdrawAmount); Console.WriteLine("Your savings account balance is now ${0}.", firstSavings.AccountBalance); choseOption = false; } else { Console.WriteLine("Please select 'a' or 'b'."); } Console.WriteLine(); } break; } case 5: isUsing = false; break; default: { Console.WriteLine("That is not an option; please select one of the menu options."); } break; } } Console.WriteLine(); Console.WriteLine("Thank you! See you next time."); }
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(); }
static void Main(string[] args) { Console.WriteLine("Welcome to the Bank of Gatlantiss."); Console.WriteLine("It is nice to see you again."); Client mikeClient = new Client(); CheckingAccount mikeCh = new CheckingAccount(); SavingsAccount mikeSv = new SavingsAccount(); //need one general object, one checking object, one savings object bool isBanking = true; while (isBanking == true) { Console.WriteLine("Please choose from the following options (choose a number):"); Console.WriteLine("\t1.\tView your account information."); Console.WriteLine("\t2.\tView your total account balance."); Console.WriteLine("\t3.\tWithdraw funds"); Console.WriteLine("\t4.\tDeposit funds"); Console.WriteLine("\t5.\tEnd Banking"); int choice = int.Parse(Console.ReadLine()); //this line reads user input if (choice == 1) //user checks client info { mikeClient.ClientInfo(); } if (choice == 2) //user checks balances { Console.WriteLine(); Console.WriteLine("Which account would you like to check?"); Console.WriteLine("\t1.\tchecking"); Console.WriteLine("\t2.\tsavings"); int choiceB = int.Parse(Console.ReadLine()); if (choiceB == 1) { mikeCh.AccountInfo(); mikeCh.InterestEarned(); } if (choiceB == 2) { mikeSv.AccountInfo(); mikeSv.InterestEarned(); } } if (choice == 3) //withdrawals { Console.WriteLine(); Console.WriteLine("From which account would you like to withdraw funds?"); Console.WriteLine("\t1.\tchecking"); Console.WriteLine("\t2.\tsavings"); int choiceB = int.Parse(Console.ReadLine()); if (choiceB == 1) { mikeCh.AccountWithdrawal(); } if (choiceB == 2) { mikeSv.AccountWithdrawal(); } } if (choice == 4) //deposits { Console.WriteLine(); Console.WriteLine("To which account would you like to deposit funds?"); Console.WriteLine("\t1.\tchecking"); Console.WriteLine("\t2.\tsavings"); int choiceB = int.Parse(Console.ReadLine()); if (choiceB == 1) { mikeCh.AccountDeposit(); } if (choiceB == 2) { mikeSv.AccountDeposit(); } } if (choice == 5) //quit program { Console.WriteLine("Thank you for banking with us today!"); Console.WriteLine("I hope we've EARNED your trust!"); Console.WriteLine("Press ENTER to leave the bank."); Console.ReadLine(); isBanking = false; //ends loop } } Environment.Exit(0); //exits program after loop ends }