private static void ShowWithdraw(ref CheckingAccount checkingAccount) { Console.Clear(); Console.WriteLine("WITHDRAW - CHECKING ACCOUNT"); Console.WriteLine("\nBalance: {0}", checkingAccount.Balance); Console.Write("\n Enter the amount to withdraw ('X' to exit screen):"); if (!decimal.TryParse(Console.ReadLine(), out decimal value)) { Console.WriteLine("Please enter valid amoutn or 'X' to exit: "); } else { try { checkingAccount.Withdraw(value); } catch (ArgumentException ex) { Console.WriteLine(); Console.WriteLine(ex.Message); Console.WriteLine("Press Enter to Continue"); Console.ReadKey(); } } }
static void Main(string[] args) { List <BankAccount> bankAccounts = new List <BankAccount>(); BankAccount account = new BankAccount(); account.AccountNo = "AC-001"; account.CustomerName = "Sharif"; account.Deposit(15000); SavingAccount sv1 = new SavingAccount(); sv1.AccountNo = "AC-002"; sv1.CustomerName = "Mohammad"; sv1.Deposit(10000); sv1.Withdraw(8000); CheckingAccount chk1 = new CheckingAccount(); chk1.AccountNo = "AC-003"; chk1.CustomerName = "Aabduallah"; chk1.Withdraw(15000); bankAccounts.Add(account); bankAccounts.Add(sv1); bankAccounts.Add(chk1); //foreach (BankAccount account in bankAccounts) //{ // Console.WriteLine(); //} }
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) { 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) { 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); }