private static void QueryLoansByRate(LoanPortfolio portfolio) { Console.Write("Enter the rate: "); decimal rate = decimal.Parse(Console.ReadLine()); rate = (rate / 100); Console.Write("Enter comparison: (< or >): "); string comparer = Console.ReadLine(); if (comparer == "<") { Console.WriteLine(); Console.WriteLine($"Loans with rates < then {rate.ToString("p")}"); foreach (var loan in portfolio.FindLoans((l) => l.Rate < rate)) { Console.WriteLine(loan); } Console.WriteLine(); Console.WriteLine(); } else { Console.WriteLine(); Console.WriteLine($"Loans with rates > then {rate.ToString("p")}"); foreach (var loan in portfolio.FindLoans((l) => l.Rate > rate)) { Console.WriteLine(loan); } Console.WriteLine(); Console.WriteLine(); } }
private static void QueryLoansByBalance(LoanPortfolio portfolio) { Console.Write("Enter the balance: "); decimal balance = decimal.Parse(Console.ReadLine()); Console.Write("Enter comparison: (< or >): "); string comparer = Console.ReadLine(); if (comparer == "<") { Console.WriteLine(); Console.WriteLine($"Loans with balance < then {balance.ToString("c")}"); foreach (var loan in portfolio.FindLoans((l) => l.Balance < balance)) { Console.WriteLine(loan); } Console.WriteLine(); Console.WriteLine(); } else { Console.WriteLine(); Console.WriteLine($"Loans with balance > then {balance.ToString("c")}"); foreach (var loan in portfolio.FindLoans((l) => l.Balance > balance)) { Console.WriteLine(loan); } Console.WriteLine(); Console.WriteLine(); } }
public static void MakePayment(LoanPortfolio portfolio) { Console.Write("Enter Loan number: "); int loanNum = int.Parse(Console.ReadLine()); Loan loan = portfolio.FindLoans((l) => l.LoanNumber == loanNum).FirstOrDefault(); if (loan != null) { Console.WriteLine("Details for loan:"); Console.WriteLine(loan); Console.WriteLine(); Console.Write("Payment amount: "); decimal paymentAmount = decimal.Parse(Console.ReadLine()); loan.MakePayment(paymentAmount); } else { Console.WriteLine("Loan not found."); } }