public double TotalInterestPaid() { double totalInterest = 0; for (int i = 0; i < accounts.Count; i++) { Account a = (Account)accounts[i]; if (a.CalculateInterest() > 0) { totalInterest += a.CalculateInterest(); } } return(totalInterest); }
public double TotalInterestEarned() { double totalEarn = 0; for (int i = 0; i < accounts.Count; i++) { Account a = (Account)accounts[i]; if (a.CalculateInterest() < 0) { totalEarn += a.CalculateInterest(); } } return(Math.Abs(totalEarn)); }
static void TestInterest(Account account, int months = 12) { Console.WriteLine(account.Customer); for (int i = 1; i <= months; i++) { Console.WriteLine(account.CalculateInterest(i)); } Console.WriteLine(); }
public double TotalInterestEarned() { double total = 0; for (int i = 0; i < accounts.Count; i++) { Account a = (Account)accounts[i]; double intr = a.CalculateInterest(); if (intr < 0) { total += (-intr); } } return(total); }
static void Main(string[] args) { Customer cus1 = new Customer("Tan Ah Kow", "2 Rich Street", "P123123", 20); Customer cus2 = new Customer("Kim May Mee", "89 Gold Road", "P334412", 60); Account a1 = new Account("S0000223", cus1, 2000); Console.WriteLine(a1.CalculateInterest()); OverdraftAccount a2 = new OverdraftAccount("O1230124", cus1, 2000); Console.WriteLine(a2.CalculateInterest()); CurrentAccount a3 = new CurrentAccount("C1230125", cus2, 2000); Console.WriteLine(a3.CalculateInterest()); Console.WriteLine(a2.Show()); a2.Withdraw(5000); //a2.TransferTo(445, a2); //OverdraftAccount does not have TransferTo method redefined, got error Console.WriteLine(a2.CalculateInterest()); Console.WriteLine(a2.Show()); }