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) { //public static void getMenu() Client newClient = new Client("Tyler", "Graves", "July 26 1990", "1426 Imaginary Ave", "135-79-2468"); CheckingAccount newChecking = new CheckingAccount(); SavingsAccount newSaving = new SavingsAccount(150); Console.WriteLine("Hello, welcome to the big bank of code!"); Console.WriteLine(); Console.WriteLine("Please select a number based on the following options"); string menuFunctions = "1,2,3,4,5"; do { Console.WriteLine("1. View client information \n 2. View account balance \n 3. Deposit funds \n 4. Withdraw funds \n 5. Exit"); string menuSelect = Console.ReadLine(); switch (menuSelect.ToLower()) { case "1": newClient.showInfo(); Console.WriteLine(); break; case "2": Console.WriteLine("Would you like an account balance for your Checking or Savings?"); string accountSelection = Console.ReadLine(); if (accountSelection == "Checking") { newChecking.DisplayAccountBalance(); Console.WriteLine(); } else if (accountSelection == "Savings") { newSaving.DisplayAccountBalance(); Console.WriteLine(); } break; case "3": Console.WriteLine("Would you like to deposit into your checking or savings account today?"); string depositSelection = Console.ReadLine(); if (depositSelection == "Checking") { newChecking.DisplayDepositAmount(); Console.WriteLine(); } else if (depositSelection == "Savings") { newSaving.DisplayDepositAmount(); Console.WriteLine(); } else { Console.WriteLine("Please select Checking or Savings"); string response = Console.ReadLine(); } break; case "4": Console.WriteLine("Would you like to withdraw from your Checking or Savings account today?"); string withdrawSelection = Console.ReadLine(); if (withdrawSelection == "Checking") { newChecking.DisplayWithdrawAmount(); Console.WriteLine(); } else if (withdrawSelection == "Savings") { newSaving.DisplayWithdrawAmount(); Console.WriteLine(); } else { Console.WriteLine("Please select Checking or Savings"); string response = Console.ReadLine(); } break; case "5": Console.WriteLine(); break; } } while (menuFunctions != "5"); }
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"); }
//Transfer Money from checking to savings. private float TransferChecking(SavingsAccount saving, CheckingAccount checking, float amount) { checking.accountMoney -= amount; saving.accountMoney += amount; return(checking.accountMoney); }
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); }