Exemple #1
0
        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();
            }
        }
Exemple #2
0
        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();
            }
        }
Exemple #3
0
        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.");
            }
        }