static void Main(string[] args) { Console.WriteLine("Bank Account System."); //SavingAccount savingAccount1 = new SavingAccount(); SavingAccount savingAccount1 = new SavingAccount("SV-101", "Sakib Khan", 1000); //savingAccount1.AccountNumber = "SV-101"; //savingAccount1.CustomerName = "Sakib Khan"; Console.WriteLine(savingAccount1.Deposit(1000)); Console.WriteLine(savingAccount1.Withdraw(1500)); Console.WriteLine(savingAccount1.Balance); Console.WriteLine("-------------------------------------"); CheckingAccount checkingAccount1 = new CheckingAccount("CK - 120", "Sarif Khan", 500); Console.WriteLine(checkingAccount1.Deposit(1000)); Console.WriteLine(checkingAccount1.Withdraw(40000)); Console.WriteLine(checkingAccount1.Balance); }
static void Main(string[] args) { // STRETCH TASK - started thinking of ideas for how to accomplish stretch task but did not finished //string clientUserName; //Console.WriteLine("Please enter your username."); //clientUserName = Console.ReadLine(); //Dictionary<string, string> userNames = new Dictionary<string, string>() //{ // { "username1", "client1" }, // { "key", "value" } // { "username2", "client2" }, // { "Dusername3", "client3" }, // { "LLusername4", "client4" } //}; //foreach (KeyValuePair<string, string> userName in userNames) //{ // if (clientUserName == userNames.Key) // if user name entered is equal to any of the keys in the dictionary // { // continue; // } // else // { // Console.WriteLine("Incorrect user name."); // } //} string returnMenuOptionSelected; Client client1 = new Client(); // instantiate client object CheckingAccount checkingAccount1 = new CheckingAccount(20000d); // instantiate checking account object with starting balance SavingsAccount savingsAccount1 = new SavingsAccount(1000000d); // instantiate savings account object with starting balance MenuOutputs accountTypeMenu = new MenuOutputs(); // instantiate account type menu object MenuOutputs invalidEntry = new MenuOutputs(); // instantiate invalid entry object MenuOutputs exitRepsonse = new MenuOutputs(); // instantiate exit response object do { Console.WriteLine("Choose an option from the menu below:"); string[] mainMenu = { "1. View Client Information", "2. View Account Balance", "3. Deposit Funds", "4. Withdraw Funds", "5. Exit" }; Console.WriteLine(mainMenu[0]); Console.WriteLine(mainMenu[1]); Console.WriteLine(mainMenu[2]); Console.WriteLine(mainMenu[3]); Console.WriteLine(mainMenu[4]); string mainMenuOptionSelected = Console.ReadLine(); if (mainMenuOptionSelected == "1") // View Client Information { client1.View(); // calls View from Client class } else if (mainMenuOptionSelected == "2") // View Account Balance { accountTypeMenu.CreateAccountTypeMenu(); string accountInformationMenuOptionSelected = Console.ReadLine().ToLower(); if (accountInformationMenuOptionSelected == "a") // Checking Account { checkingAccount1.View(); // calls View from CheckingAccount class } else if (accountInformationMenuOptionSelected == "b") // Savings Account { savingsAccount1.View(); // calls View from SavingsAccount class } else { invalidEntry.InvalidEntryResponse(); } } else if (mainMenuOptionSelected == "3") // Deposit Funds { accountTypeMenu.CreateAccountTypeMenu(); string depositFundsMenuOptionSelected = Console.ReadLine().ToLower(); if (depositFundsMenuOptionSelected == "a") // Checking Account { checkingAccount1.Deposit(); // calls Deposit from CheckingAccount class } else if (depositFundsMenuOptionSelected == "b") // Savings Account { savingsAccount1.Deposit(); // calls Deposit from SavingsAccount class } else { invalidEntry.InvalidEntryResponse(); } } else if (mainMenuOptionSelected == "4") // Withdraw Funds { accountTypeMenu.CreateAccountTypeMenu(); string withdrawFundsMenuOptionSelected = Console.ReadLine().ToLower(); if (withdrawFundsMenuOptionSelected == "a") // Checking Account { Console.WriteLine("Current balance: $" + checkingAccount1.Withdraw()); // calls Deposit from CheckingAccount class } else if (withdrawFundsMenuOptionSelected == "b") // Savings Account { Console.WriteLine("Current balance: $" + savingsAccount1.Withdraw()); // calls Deposit from SavingsAccount class } else { invalidEntry.InvalidEntryResponse(); } } else if (mainMenuOptionSelected == "5") // Exit { exitRepsonse.ExitResponse(); return; } else { invalidEntry.InvalidEntryResponse(); } Console.WriteLine("Return to main menu or exit?"); string[] returnMenu = { "1. Main Menu", "2. Exit" }; Console.WriteLine(returnMenu[0]); Console.WriteLine(returnMenu[1]); returnMenuOptionSelected = Console.ReadLine(); if (returnMenuOptionSelected == "2") { exitRepsonse.ExitResponse(); } }while (returnMenuOptionSelected == "1"); // returns to main menu }
static void Main(string[] args) { // Create an instance of each Account / Instantiate Accounts CheckingAccount Checking = new CheckingAccount(); ReserveAccount Reserve = new ReserveAccount(); SavingsAccount Savings = new SavingsAccount(); // Instantiate StreamWriter for each account & to write to a file StreamWriter wChecking = new StreamWriter("CheckingAccount.txt"); StreamWriter wReserve = new StreamWriter("ReserveAccount.txt"); StreamWriter wSavings = new StreamWriter("SavingsAccount.txt"); Console.WriteLine("Welcome to My Bank Account"); Console.WriteLine("Type your First Name"); string accountHolderFirstName = Console.ReadLine(); Console.WriteLine("Type your Last Name"); string accountHolderLastName = Console.ReadLine(); string fullAccountHolderName = string.Concat(accountHolderFirstName, " ", accountHolderLastName); { // do-while loop int usersNumber = 0; do { Console.WriteLine(" View Customer Information: choose 1 "); Console.WriteLine(" View Checking Account Balance: choose 2 "); Console.WriteLine(" View Reserve Account Balance: choose 3 "); Console.WriteLine(" View Savings Account Balance: choose 4 "); Console.WriteLine(" Make a Deposit into an Account: choose 5 "); Console.WriteLine(" Make a Withdrawal from an Account: choose 6 "); Console.WriteLine(" QUIT / EXIT Bank Account Program: choose 7 "); Console.WriteLine(" TYPE your choice as a number 1, 2, 3, 4, 5, 6, or 7 "); string usersResponse = Console.ReadLine(); usersNumber = Convert.ToInt32(usersResponse); switch (usersNumber) { case 1: Checking.BankAccountInfo(); break; case 2: Checking.AccountBalance(); break; case 3: Reserve.AccountBalance(); break; case 4: Savings.AccountBalance(); break; case 5: Console.WriteLine(" Which Account would you like to make a Deposit "); Console.WriteLine(" Checking Account (Deposit): choose 1 "); Console.WriteLine(" Reserve Account (Deposit): choose 2 "); Console.WriteLine(" Savings Account (Deposit): choose 3 "); int userChoice = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How Much would you like to Deposit"); decimal deposit = Convert.ToDecimal(Console.ReadLine()); switch (userChoice) { case 1: Checking.Deposit(deposit); Console.WriteLine(" Checking Account New Balance: ${0} ", Checking.CheckingAccountBalance); using (wChecking) { wChecking.WriteLine(fullAccountHolderName); wChecking.WriteLine(" Checking Account No.: {0} ", Checking.CheckingAccountNo); wChecking.WriteLine(DateTime.Now); wChecking.WriteLine(" + :$ {0}", deposit); wChecking.WriteLine(" Checking Account New Balance: {0} ", Checking.CheckingAccountBalance); } break; case 2: Reserve.Deposit(deposit); Console.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance); using (wReserve) { wReserve.WriteLine(fullAccountHolderName); wReserve.WriteLine(" Reserve Account No.: {0} ", Reserve.ReserveAccountNo); wReserve.WriteLine(DateTime.Now); wReserve.WriteLine(" + :$ {0}", deposit); wReserve.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance); } break; case 3: Savings.Deposit(deposit); Console.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance); using (wSavings) { wSavings.WriteLine(fullAccountHolderName); wSavings.WriteLine(" Reserve Account No.: {0} ", Savings.SavingsAccountNo); wSavings.WriteLine(DateTime.Now); wSavings.WriteLine(" + :$ {0}", deposit); wSavings.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance); } break; default: Console.WriteLine(" Invalid selection "); Console.WriteLine(" Please choose Deposit option 1, 2, or, 3 "); break; } break; case 6: Console.WriteLine(" Which Account would you like to make a Withdrawal from "); Console.WriteLine(" Checking Account (Withdrawal): choose 1 "); Console.WriteLine(" Reserve Account (Withdrawal): choose 2 "); Console.WriteLine(" Savings Account (Withdrawal): choose 3 "); int userOption = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("How Much would you like to Withdraw"); decimal withdrawal = Convert.ToDecimal(Console.ReadLine()); switch (userOption) { case 1: Checking.Withdrawal(withdrawal); Console.WriteLine(" Check Account New Balance: ${0} ", Checking.CheckingAccountBalance); using (wChecking) { wChecking.WriteLine(fullAccountHolderName); wChecking.WriteLine(" Checking Account No.: {0} ", Checking.CheckingAccountNo); wChecking.WriteLine(DateTime.Now); wChecking.WriteLine(" - :$ {0}", withdrawal); wChecking.WriteLine(" Check Account New Balance: {0} ", Checking.CheckingAccountBalance); } break; case 2: Reserve.Withdrawal(withdrawal); Console.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance); using (wReserve) { wReserve.WriteLine(fullAccountHolderName); wReserve.WriteLine(" Reserve Account No.: {0} ", Reserve.ReserveAccountNo); wReserve.WriteLine(DateTime.Now); wReserve.WriteLine(" + :$ {0}", withdrawal); wReserve.WriteLine(" Reserve Account New Balance: ${0} ", Reserve.ReserveAccountBalance); } break; case 3: Savings.Withdrawal(withdrawal); Console.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance); using (wSavings) { wSavings.WriteLine(fullAccountHolderName); wSavings.WriteLine(" Savings Account No.: {0} ", Savings.SavingsAccountNo); wSavings.WriteLine(DateTime.Now); wSavings.WriteLine(" + :$ {0}", withdrawal); wSavings.WriteLine(" Savings Account New Balance: ${0} ", Savings.SavingsAccountBalance); } break; default: Console.WriteLine(" Invalid selection "); Console.WriteLine(" Please choose Deposit option 1, 2, or, 3 "); break; } break; case 7: Console.WriteLine(" Thank you for using My Bank Account Program "); Console.WriteLine(" , use our program anytime "); Environment.Exit(0); break; default: Console.WriteLine(" Invalid Selection "); Console.WriteLine(" Please choose number 1, 2, 3, 4, 5, 6, or, 7 "); break; } }while (usersNumber != 7); } }
static void Main(string[] args) { int selection; //Instantiate objects Client johnSmith = new Client(); CheckingAccount jsChecking = new CheckingAccount(); SavingsAccount jsSavings = new SavingsAccount(); //Ask for user input Console.WriteLine("Hello and welcome to Lehman Brothers. \nHere you can view your account information."); Console.WriteLine("It is 2008 and we promise that subprime lending is always a wise investment."); Console.WriteLine("We also guarantee to never file for bankruptcy."); do { Console.WriteLine("\nPlease select from the following options: \n1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit"); //Variables based on user input selection = int.Parse(Console.ReadLine()); char account; if (selection == 1) { Console.WriteLine(johnSmith.GetClientInfo()); } if (selection == 2) { Console.WriteLine("Which account would you like to view the balance of?"); Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account"); account = char.Parse(Console.ReadLine().ToLower()); if (account == 'a') { jsChecking.GetBalance(); } if (account == 'b') { jsSavings.GetBalance(); } } if (selection == 3) { Console.WriteLine("To which account would you like to make a deposit?"); Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account"); account = char.Parse(Console.ReadLine().ToLower()); if (account == 'a') { jsChecking.Deposit(); } if (account == 'b') { jsSavings.Deposit(); } } if (selection == 4) { Console.WriteLine("From which account would you like to make a withdrawal?"); Console.WriteLine("Please select:\na. Checking Account\nb. Savings Account"); account = char.Parse(Console.ReadLine().ToLower()); if (account == 'a') { jsChecking.Withdraw(); } if (account == 'b') { jsSavings.Withdraw(); } } }while (selection != 5); }
static void Main(string[] args) { Client mem = new Client(); CheckingAccount check = new CheckingAccount(); SavingAccount save = new SavingAccount(); int input; do { Console.WriteLine("\nView Client Informatin: Select 1"); Console.WriteLine("View Account Balance: select 2"); Console.WriteLine("Deposit Funds select 3"); Console.WriteLine("Withdraw Fund Select 4"); Console.WriteLine("Exit select 5"); input = int.Parse(Console.ReadLine()); switch (input) { case 1: mem.ClientInfo(); break; case 2: Console.WriteLine("Checking Account Select 1\n Savings Account select 2"); int acc; acc = int.Parse(Console.ReadLine()); switch (acc) { case 1: Console.WriteLine("\nChecking account Balance amount:" + check.BalanceAmount()); break; case 2: Console.WriteLine("\nSaving account Balance amount:" + save.BalanceAmount()); save.BalanceAmount(); break; default: break; } break; case 3: Console.WriteLine("Checking Account Select 1\n Savings Account select 2"); int acc1; acc1 = int.Parse(Console.ReadLine()); switch (acc1) { case 1: Console.WriteLine("enter the amount to deposit"); int amount = int.Parse(Console.ReadLine()); check.Deposit(amount); break; case 2: Console.WriteLine("enter the amount to deposit"); int amount1 = int.Parse(Console.ReadLine()); save.Deposit(amount1); break; default: break; } break; case 4: Console.WriteLine("Checking Account Select 1\n Savings Account select 2"); int acc2; acc2 = int.Parse(Console.ReadLine()); switch (acc2) { case 1: Console.WriteLine("enter the amount to withdraw"); int amount = int.Parse(Console.ReadLine()); check.Withdraw(amount); break; case 2: Console.WriteLine("enter the amount to Withdraw"); int amount1 = int.Parse(Console.ReadLine()); save.Withdraw(amount1); break; default: break; } break; case 5: Console.WriteLine("Signed Out"); break; } } while (input != 5); }
static void Main(string[] args) { //instantiating our client and accounts. Client oswaldCobblepot = new Client(); CheckingAccount oswaldChecking = new CheckingAccount(); SavingsAccount oswaldSavings = new SavingsAccount(); string firstChoice; string secondChoice; double deposit; double withdraw; do { // Welcome user and give them the menu to make their choices. Console.WriteLine("Welcome to Gotham National Bank."); Console.WriteLine("Please make a selection from the following menu.\n"); Console.WriteLine("1. View Client Information\n2. View Account Balance\n3. Deposit Funds\n4. Withdraw Funds\n5. Exit\nPlease enter the number of your choice"); firstChoice = Console.ReadLine(); Console.Clear(); //prints users info if (firstChoice == "1") { oswaldCobblepot.Info(); Console.WriteLine("Press enter when done."); Console.ReadLine(); Console.Clear(); } //Shows balances of users accounts if (firstChoice == "2") { do { Console.WriteLine("1. Checking Account Balance\n2. Savings Account Balance\n3. Back\n4. Exit"); secondChoice = Console.ReadLine(); Console.Clear(); if (secondChoice == "1") { Console.WriteLine("Your checking account balance is :"); oswaldChecking.GetBalance(); } if (secondChoice == "2") { Console.WriteLine("Your savings account balance is :"); oswaldSavings.GetBalance(); } if (secondChoice == "3") { break; } if (secondChoice == "4") { firstChoice = "5"; break; } } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4"); } //allows user to deposit funds in their account. if (firstChoice == "3") { do { Console.WriteLine("In which account would you like to make a deposit?\n1. Checking Account\n2. Savings Account\n3. Back\n4. Exit"); secondChoice = Console.ReadLine(); Console.Clear(); if (secondChoice == "1") { Console.WriteLine("How much would you like to deposit?"); deposit = double.Parse(Console.ReadLine()); oswaldChecking.Balance = oswaldChecking.Deposit(deposit); Console.WriteLine("Your new balance is "); oswaldChecking.GetBalance(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); Console.Clear(); } if (secondChoice == "2") { Console.WriteLine("How much would you like to deposit?"); deposit = double.Parse(Console.ReadLine()); oswaldSavings.Balance = oswaldSavings.Deposit(deposit); Console.WriteLine("Your new balance is "); oswaldSavings.GetBalance(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); Console.Clear(); } if (secondChoice == "3") { break; } if (secondChoice == "4") { firstChoice = "5"; break; } } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4"); } //allows user to withdraw money from accounts if (firstChoice == "4") { do { Console.WriteLine("In which account would you like to make a withdraw?\n1. Checking Account\n2. Savings Account\n3. Back\n4. Exit"); secondChoice = Console.ReadLine(); Console.Clear(); if (secondChoice == "1") { Console.WriteLine("How much would you like to withdraw?"); withdraw = double.Parse(Console.ReadLine()); oswaldChecking.Balance = oswaldChecking.Withdraw(withdraw); Console.WriteLine("Your new balance is "); oswaldChecking.GetBalance(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); Console.Clear(); } if (secondChoice == "2") { Console.WriteLine("How much would you like to withdraw?"); withdraw = double.Parse(Console.ReadLine()); //Checking to make sure savings account does not go below zero. if (withdraw > oswaldSavings.Balance) { Console.WriteLine("Can not continue this transaction.\nInsuffient Funds."); Console.WriteLine("Press enter to continue."); Console.ReadLine(); Console.Clear(); break; } oswaldSavings.Balance = oswaldSavings.Withdraw(withdraw); Console.WriteLine("Your new balance is "); oswaldSavings.GetBalance(); Console.WriteLine("Press enter to continue"); Console.ReadLine(); Console.Clear(); } if (secondChoice == "3") { break; } if (secondChoice == "4") { firstChoice = "5"; break; } } while (secondChoice != "1" || secondChoice != "2" || secondChoice != "3" || secondChoice != "4"); } } while (firstChoice != "5"); Console.WriteLine("Have a great day!"); }
static void Main(string[] args) { string answer; Console.WriteLine("Welcome to your bank!"); Client cl = new Client("Ferris", "Bueller", "1234 Chicago, Illinois", "555-0095"); SavingsAccount sa = new SavingsAccount(1000.75M); CheckingAccount ca = new CheckingAccount(1000.25M); decimal BalanceValue = 100; do { Console.WriteLine("Please enter your selection!"); Console.WriteLine("1. View Client Information"); Console.WriteLine("2. View Account Balance"); Console.WriteLine("3. Deposit Funds"); Console.WriteLine("4. Withdraw Funds"); Console.WriteLine("5. Exit"); answer = (Console.ReadLine()); if (answer == "1") { cl.GetClientInfo(); Console.WriteLine("Press any key to continue"); answer = (Console.ReadLine()); } if (answer == "2") { Console.WriteLine("a. Checking Account\nb. Savings Account"); string selection = Console.ReadLine().ToLower(); if (selection == "a") { Console.WriteLine("Checking account balance is {0:C}", ca.Balance); answer = (Console.ReadLine()); } if (selection == "b") { Console.WriteLine("Savings account balance is {0:C}", sa.Balance); answer = (Console.ReadLine()); } else { continue; } } if (answer == "3") { Console.WriteLine("a. Deposit Into Checking Account\nb. Deposit Into Savings Account"); string selection = Console.ReadLine().ToLower(); if (selection == "a") { Console.WriteLine("How much would you like to deposit?"); decimal credit = decimal.Parse(Console.ReadLine()); ca.Balance = ca.Deposit(credit); Console.WriteLine("Your new balance is " + ca.Balance); } if (selection == "b") { Console.WriteLine("How much would you like to deposit?"); decimal credit = decimal.Parse(Console.ReadLine()); sa.Balance = sa.Deposit(credit); Console.WriteLine("Your new balance is " + sa.Balance); } else { continue; } } if (answer == "4") { Console.WriteLine("a. Withdraw From Checking Account\nb. Withdraw From Savings Account"); string selection = Console.ReadLine().ToLower(); if (selection == "a") { Console.WriteLine("How much would you like to withdraw?"); decimal debit = decimal.Parse(Console.ReadLine()); if (debit > ca.Balance) { Console.WriteLine("Insufficient Funds, enter a different amount"); debit = decimal.Parse(Console.ReadLine()); } ca.Balance = ca.Withdraw(debit); Console.WriteLine("Your new balance is " + ca.Balance); } if (selection == "b") { Console.WriteLine("How much would you like to withdraw?"); decimal debit = decimal.Parse(Console.ReadLine()); if (debit > sa.Balance - BalanceValue) { Console.WriteLine("Insufficient Funds, enter a different amount"); debit = decimal.Parse(Console.ReadLine()); } sa.Balance = sa.Withdraw(debit); Console.WriteLine("Your new balance is " + sa.Balance); } else { continue; } } } while (answer != "5"); }
static void Main(string[] args) { //Bank Account Project //Ryan Sizer //Week 3 - 04/17/2017 //Instantiate a new object of Client class Client client1 = new Client(); //Instantiate a new object of CheckingAccount class CheckingAccount checking1 = new CheckingAccount("12345", "Lord Tyrion's Checking Account", 25236755.23, 77000500.51); //Instantiate a new object of SavingsAccount class SavingsAccount savings1 = new SavingsAccount("12345", "Lord Tyrion's Savings Account", 25236755.23, 77000500.51); //client1.DisplayClientInfo(); //Greet the user Console.WriteLine("Hello, Mr. Lannister. Welcome to your Bank Account.\r\n"); //Use a do-while loop for the menu and to keep program running until user exits do { //Store menu options in a string string menu = ("BANK OF WESTEROS" + Environment.NewLine + "----------------------------------" + Environment.NewLine + "- [1] View Client Information" + Environment.NewLine + "- [2] View Account Balance" + Environment.NewLine + "- [3] Deposit Funds" + Environment.NewLine + "- [4] Withdraw Funds" + Environment.NewLine + "- [5] Exit Program" + Environment.NewLine); //Display menu options Console.WriteLine(menu); //Store user response in a string variable string menuChoice = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(menuChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option between 1 and 5: "); Console.WriteLine(menu); menuChoice = Console.ReadLine(); } //Declare variable to hold the converted value of menu selection int menuInt; //Convert with TryParse int.TryParse(menuChoice, out menuInt); //Validate that user made a numerical choice between 1 and 5 while (menuInt < 1 || menuInt > 5) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You selected something other than a number between 1 and 5.\r\nPlease try again and make a menu selection between 1 and 5."); Console.WriteLine(menu); //Re-capture user response menuChoice = Console.ReadLine(); //re-convert to an integer int.TryParse(menuChoice, out menuInt); } Console.Clear(); //Use switch case for user menu selections switch (menuInt) { //When user selects option one, client information is displayed case 1: client1.DisplayClientInfo(); break; //When user selects option two, display submenu so they can select checkings or savings case 2: //Store submenu in a string string balanceSubMenu = ("BANK OF WESTEROS" + Environment.NewLine + "----------------------------------" + Environment.NewLine + "- [1] View Checking Account Balance" + Environment.NewLine + "- [2] View Savings Account Balance" + Environment.NewLine); Console.WriteLine(balanceSubMenu); //Display submenu to console string balanceChoice = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(balanceChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: "); Console.WriteLine(balanceSubMenu); balanceChoice = Console.ReadLine(); } //Declare variable to hold the converted value of menu selection int balanceChoiceInt; //Convert with TryParse int.TryParse(balanceChoice, out balanceChoiceInt); //Validate that user made a numerical choice between 1 and 5 while (balanceChoiceInt < 1 || balanceChoiceInt > 2) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n"); Console.WriteLine(balanceSubMenu); //Re-capture user response balanceChoice = Console.ReadLine(); //re-convert to an integer int.TryParse(balanceChoice, out balanceChoiceInt); } if (balanceChoiceInt == 1) { checking1.ViewBalance(); } if (balanceChoiceInt == 2) { //savings1.DefaultSavingsBal(); savings1.ViewBalance(); } break; //When user selects option three, display submenu so they can select checkings or savings case 3: //Store submenu in a string string depositSubMenu = ("BANK OF WESTEROS" + Environment.NewLine + "----------------------------------" + Environment.NewLine + "- [1] Deposit Funds into Checking Account" + Environment.NewLine + "- [2] Deposit Funds into Savings Account" + Environment.NewLine); Console.WriteLine(depositSubMenu); //Display submenu to console string depositChoice = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(depositChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: "); Console.WriteLine(depositChoice); depositChoice = Console.ReadLine(); } //Declare variable to hold the converted value of menu selection int depositChoiceInt; //Convert with TryParse int.TryParse(depositChoice, out depositChoiceInt); //Validate that user made a numerical choice between 1 and 5 while (depositChoiceInt < 1 || depositChoiceInt > 2) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n"); Console.WriteLine(depositSubMenu); //Re-capture user response depositChoice = Console.ReadLine(); //re-convert to an integer int.TryParse(depositChoice, out depositChoiceInt); } if (depositChoiceInt == 1) { Console.WriteLine("Please enter the amount of money you wish to deposit into your checking account:\r\n"); string depositAmount = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(depositChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't deposit anything.\r\nPlease enter the amount you wish to deposit: "); depositAmount = Console.ReadLine(); } //Declare variable to hold the converted value of deposit amount double depositAmountDouble; //Convert with TryParse double.TryParse(depositAmount, out depositAmountDouble); //Call methods for transactions checking1.Deposit(depositAmountDouble); checking1.PrintDepBalance(); } if (depositChoiceInt == 2) { Console.WriteLine("Please enter the amount of money you wish to deposit into your savings account:\r\n"); string depositAmount = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(depositChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't deposit anything.\r\nPlease enter the amount you wish to deposit: "); depositAmount = Console.ReadLine(); } //Declare variable to hold the converted value of deposit amount double depositAmountDouble; //Convert with TryParse double.TryParse(depositAmount, out depositAmountDouble); //Call methods for transaction savings1.Deposit(depositAmountDouble); savings1.PrintDepBalance(); } break; case 4: //Store submenu in a string string withdrawSubMenu = ("BANK OF WESTEROS" + Environment.NewLine + "----------------------------------" + Environment.NewLine + "- [1] Withdraw Funds from Checking Account" + Environment.NewLine + "- [2] Withdraw Funds from Savings Account" + Environment.NewLine); Console.WriteLine(withdrawSubMenu); //Display submenu to console string withdrawChoice = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(withdrawChoice)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't select anything.\r\nPlease select a menu option of 1 or 2: "); Console.WriteLine(withdrawChoice); depositChoice = Console.ReadLine(); } //Declare variable to hold the converted value of menu selection int withdrawChoiceInt; //Convert with TryParse int.TryParse(withdrawChoice, out withdrawChoiceInt); //Validate that user made a numerical choice between 1 and 5 while (withdrawChoiceInt < 1 || withdrawChoiceInt > 2) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You selected something other than a number of 1 or 2.\r\nPlease try again and make a menu selection of 1 or 2.\r\n"); Console.WriteLine(withdrawSubMenu); //Re-capture user response withdrawChoice = Console.ReadLine(); //re-convert to an integer int.TryParse(withdrawChoice, out withdrawChoiceInt); } if (withdrawChoiceInt == 1) { Console.WriteLine("Please enter the amount of money you wish to withdraw from your checking account:\r\n"); string withdrawAmount = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(withdrawAmount)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't withdraw anything.\r\nPlease enter the amount you wish to withdraw: "); withdrawAmount = Console.ReadLine(); } //Declare variable to hold the converted value of deposit amount double withdrawAmountDouble; //Convert with TryParse double.TryParse(withdrawAmount, out withdrawAmountDouble); //Call on methods for transaction checking1.Withdrawal(withdrawAmountDouble); checking1.TransactionFee(); checking1.PrintWithdrawBalance(); } if (withdrawChoiceInt == 2) { Console.WriteLine("Please enter the amount of money you wish to withdraw from your savings account:\r\n"); string withdrawAmount = Console.ReadLine(); //Validate if user input anything while (string.IsNullOrWhiteSpace(withdrawAmount)) { Console.Clear(); //Tell user what went wrong Console.WriteLine("Oops! You didn't withdraw anything.\r\nPlease enter the amount you wish to withdraw: "); withdrawAmount = Console.ReadLine(); } //Declare variable to hold the converted value of deposit amount double withdrawAmountDouble; //Convert with TryParse double.TryParse(withdrawAmount, out withdrawAmountDouble); //Call methods for the transaction savings1.Withdrawal(withdrawAmountDouble); savings1.TransactionFee(); savings1.PrintWithdrawBalance(); } break; case 5: Console.Clear(); Console.WriteLine("Thank you for banking with us! Goodbye!\r\n\r\n"); //Goodbye message for user return; default: break; } } while (true); }
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"); //ask for name Console.WriteLine("Please enter your name for your password."); string holderName = Console.ReadLine(); Console.Clear(); //create objects to use classes SavingsAccount savings = new SavingsAccount(holderName); CheckingAccount checking = new CheckingAccount(holderName); ReserveAccount reserve = new ReserveAccount(holderName); //beginning of text file for each account accountChecking.WriteLine("Account Holder: " + holderName); accountChecking.WriteLine("Account Number: " + checking.AccountNumber); accountChecking.WriteLine("Account Type: Checking Account"); accountChecking.WriteLine("Account Balance: " + checking.AccountBalance); accountSavings.WriteLine("Account Holder: " + holderName); accountSavings.WriteLine("Account Number: " + savings.AccountNumber); accountSavings.WriteLine("Account Type: Savings Account"); accountSavings.WriteLine("Account Balance: " + savings.AccountBalance); accountReserve.WriteLine("Account Holder: " + holderName); 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! What would you like to do?"); Console.WriteLine("1: View Client Information"); Console.WriteLine("View Account Balance of:"); 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"); Console.WriteLine("7: Exit"); //user choose for which action on menu int action = int.Parse(Console.ReadLine()); Console.Clear(); //action for what happens when the user makes a choose switch (action) { case 1: //calls method from account to show client info savings.ClientInfo(); break; case 2: //calls method from checking to view balance checking.ViewAccountBalance(); break; case 3: //views savings balance savings.ViewAccountBalance(); break; case 4: //views reserve balance reserve.ViewAccountBalance(); break; case 5: //asks user where they want to make a deposit and the adds funds to that account Console.WriteLine("Where would you like to make a deposit?"); Console.WriteLine("1: Checking Account"); Console.WriteLine("2: Savings Account"); Console.WriteLine("3: Reserve Account"); int choice = int.Parse(Console.ReadLine()); Console.WriteLine("How much would you like to deposit?"); int deposit = int.Parse(Console.ReadLine()); switch (choice) { case 1: checking.Deposit(deposit); Console.WriteLine("The new balance is " + checking.AccountBalance); accountChecking.WriteLine("+ " + deposit + " " + DateTime.Now); accountChecking.WriteLine("Account Balance: " + checking.AccountBalance); break; case 2: savings.Deposit(deposit); Console.WriteLine("The new balance is " + savings.AccountBalance); accountSavings.WriteLine("+ " + deposit + " " + DateTime.Now); accountSavings.WriteLine("Account Balance: " + savings.AccountBalance); break; case 3: reserve.Deposit(deposit); Console.WriteLine("The new balance is " + reserve.AccountBalance); accountReserve.WriteLine("+ " + deposit + " " + DateTime.Now); accountReserve.WriteLine("Account Balance: " + reserve.AccountBalance); break; default: break; } break; case 6: //asks user where to withdrawal and then takes funds from that account Console.WriteLine("Where would you like to make a withdrawal?"); Console.WriteLine("1: Checking Account"); Console.WriteLine("2: Savings Account"); Console.WriteLine("3: Reserve Account"); int pick = int.Parse(Console.ReadLine()); Console.WriteLine("How much would you like to withdrawal?"); int withdrawal = int.Parse(Console.ReadLine()); 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; case 7: //quits to ask if they want to do anything else break; default: //quits to ask if they want to do anything else break; } Console.WriteLine("Would you like to do something else? Y or N?"); string yesOrNo = Console.ReadLine(); if (yesOrNo.ToLower() == "y") { //clears console and goes back to the menu since in a loop Console.Clear(); } else { //breaks out of loop and quits the program Console.Clear(); break; } } //closes the streamwriters accountReserve.Close(); accountSavings.Close(); accountChecking.Close(); Quit(); }
static void Main(string[] args) { CheckingAccount checkBalance = new CheckingAccount(535.78, 24681013, "Checking", 5); ///need input inside the method, but for some reason it doesn't matter what number is there because it does not effect my program. not sure why. ///ex. 5 for checking account and 23 for savings (random numbers) SavingsAccount saveBalance = new SavingsAccount(898.15, 35791113, "Savings", 23); Client userClient = new Client(); string transInput = "";//transInput is the users input if they have another transaction or not (YES/NO) do { Console.WriteLine("1. View Client Information"); Console.WriteLine("2. View Account Balance"); Console.WriteLine("3. Deposit Funds"); Console.WriteLine("4. Withdraw Funds"); Console.WriteLine("5. Exit"); Console.WriteLine("Please enter a number for the action you would like to perfom."); int userInput = int.Parse(Console.ReadLine()); string accountInput = " ";//accountInput is when the user types "C" or "S" for which account they would like to perform there action in switch (userInput) { case 1: userClient.ClientInfo(); Console.WriteLine(userClient.Name); Console.WriteLine(userClient.Address); Console.WriteLine(userClient.TelephoneNumber); Console.WriteLine("Do you have another transaction? YES/NO"); transInput = Console.ReadLine().ToUpper(); break; case 2: Console.WriteLine("Would you like the balance of your Checking Account or Savings Account? Enter C for Checking or S for Savings."); accountInput = Console.ReadLine().ToUpper(); if (accountInput == "C") { checkBalance.AccountInfo(); Console.WriteLine(checkBalance.Balance); } else if (accountInput == "S") { saveBalance.SaveAccountInfo(); Console.WriteLine(saveBalance.Balance); } Console.WriteLine("Do you have another transaction? YES/NO"); transInput = Console.ReadLine().ToUpper(); break; case 3: Console.WriteLine("Which account would you like to deposit funds into? Enter C for Checking or S for Savings."); accountInput = Console.ReadLine().ToUpper(); if (accountInput == "C") { Console.WriteLine("Please enter the amount you would like to deposit."); checkBalance.Deposit(); Console.WriteLine("Your new balance is " + checkBalance.Balance); } else if (accountInput == "S") { Console.WriteLine("Please enter the amount you would like to deposit."); saveBalance.Deposit(); Console.WriteLine("Your new balance is " + saveBalance.Balance); } Console.WriteLine("Do you have another transaction? YES/NO"); transInput = Console.ReadLine().ToUpper(); break; case 4: Console.WriteLine("Which account would you like to withdraw funds from? Enter C for Checking or S for Savings."); accountInput = Console.ReadLine().ToUpper(); if (accountInput == "C") { Console.WriteLine("Please enter the amount you would like to withdraw."); checkBalance.Withdraw(); Console.WriteLine("Your new balance is " + checkBalance.Balance); } else if (accountInput == "S") { Console.WriteLine("Please enter the amount you would like to withdraw."); saveBalance.Withdraw(); Console.WriteLine("Your new balance is " + saveBalance.Balance); } Console.WriteLine("Do you have another transaction? YES/NO"); transInput = Console.ReadLine().ToUpper(); break; case 5: Console.WriteLine("Goodbye!"); break; } }while (transInput == "YES"); }
static void Main(string[] args) { Client nietzsche = new Client("Friedrich", "Nietzsche", 1532980, 2968351); CheckingAccount nietzscheChecking = new CheckingAccount(); SavingsAccount nietzscheSavings = new SavingsAccount(); // user menu int userChoice = 0; string userChoiceMenu; do { Console.WriteLine("Welcome to the bank account program."); Console.WriteLine(""); Console.WriteLine("Please select one of the following options:"); Console.WriteLine("[1] View client information."); Console.WriteLine("[2] View account balance:"); Console.WriteLine(" [ ] Checking account balance."); Console.WriteLine(" [ ] Savings account balance."); Console.WriteLine("[3] Deposit funds:"); Console.WriteLine(" [ ] In checking account."); Console.WriteLine(" [ ] In savings account."); Console.WriteLine("[4] Withdraw funds:"); Console.WriteLine(" [ ] From checking account."); Console.WriteLine(" [ ] From savings account."); Console.WriteLine("[5] Exit."); userChoice = int.Parse(Console.ReadLine()); switch (userChoice) { case 1: nietzsche.DisplayAccountInformation(); Console.WriteLine("Press any key to continue."); Console.ReadLine(); Console.Clear(); break; case 2: Console.WriteLine("To check your checking acccount balance, type \"checking.\""); Console.WriteLine("To check your savings account balance, type \"savings.\""); userChoiceMenu = Console.ReadLine().ToLower(); if (userChoiceMenu == "checking") { Console.WriteLine("Your balance is $" + nietzscheChecking.CheckBalance()); } else { Console.WriteLine("Your balance is $" + nietzscheSavings.CheckBalance()); } Console.WriteLine("Press any key to continue."); Console.ReadLine(); Console.Clear(); break; case 3: Console.WriteLine("To deposit funds into your checking account, type \"checking.\""); Console.WriteLine("To deposit funds into your savings account, type \"savings.\""); userChoiceMenu = Console.ReadLine().ToLower(); if (userChoiceMenu == "checking") { nietzscheChecking.Deposit(); } else { nietzscheSavings.Deposit(); } Console.WriteLine("Press any key to continue."); Console.ReadLine(); Console.Clear(); break; case 4: Console.WriteLine("To withdraw funds from your checking account, type \"checking.\""); Console.WriteLine("To withdraw funds from your savings account, type \"savings.\""); userChoiceMenu = Console.ReadLine().ToLower(); if (userChoiceMenu == "checking") { nietzscheChecking.Withdraw(); } else { nietzscheSavings.Withdraw(); } Console.WriteLine("Press any key to continue."); Console.ReadLine(); Console.Clear(); break; } } while (userChoice != 5); }