static void addFunds(SavingsAccount currentCust) { bool quitNow = false; while (!quitNow) { string depositInput = Console.ReadLine(); double deposit; bool gotDeposit = double.TryParse(depositInput, out deposit); if (!gotDeposit) { Console.WriteLine("That is not a valid value. Please try again."); } else { Console.WriteLine("You entered {0:c}. Is this correct? Y/N", deposit); bool depositCorrect = confirm(); if (!depositCorrect) { gotDeposit = false; } else { currentCust.makeDeposit(deposit); currentCust.updateBalance(); quitNow = true; } } } }
static void withdrawFunds() { if (customerList.Count == 0) { Console.WriteLine("There are no customers in the system.\nPlease create a customer or load saved customers.\n"); } else { SavingsAccount currentCust = new SavingsAccount(); bool quitNow = false; while (!quitNow) { showCustomers(true); Console.WriteLine("Please choose the account from which you would like to make a withdrawal."); int custIndex = inputIndex(); if (custIndex < 1 || custIndex > customerList.Count) { Console.Clear(); Console.WriteLine("That is not a valid customer. Please try again.\n"); } else if (customerList[custIndex - 1].Balance == 0) { Console.WriteLine("There are no funds in that account to withdraw."); quitNow = true; } else { currentCust = customerList[custIndex - 1]; Console.Clear(); displayCustomer(currentCust); bool gotWithdrawal = false; double withdrawal; while (!gotWithdrawal) { Console.WriteLine("How much would you like to withdraw?"); string withdrawalInput = Console.ReadLine(); gotWithdrawal = double.TryParse(withdrawalInput, out withdrawal); if (!gotWithdrawal) { Console.WriteLine("That is not a valid value. Please try again."); } else { Console.WriteLine("You entered {0:c}. Is this correct? Y/N", withdrawal); bool withdrawalCorrect = confirm(); if (!withdrawalCorrect) { gotWithdrawal = false; } else if (withdrawal > currentCust.Balance) { Console.WriteLine("The withdrawal amount is greater than the account balance. Please try again."); gotWithdrawal = false; } else { currentCust.makeWithdrawal(withdrawal); currentCust.updateBalance(); Console.WriteLine("Withdrawal made successfully."); Console.WriteLine("The current balance in this account is {0:C}.", currentCust.Balance); Console.WriteLine("The balance in 1 year, compounded monthly at {0:p} will be {1:C}", currentCust.Interest, currentCust.FutureBalance); } } } quitNow = true; } } } }