Exemple #1
0
        private static void PrePopulateLoans(LoanPortfolio portfolio)
        {
            Random rand     = new Random(DateTime.Now.Second);
            int    numLoans = rand.Next(2, 5);

            for (int i = 0; i < numLoans; i++)
            {
                int     loanNum       = _nextLoanNumber++;
                decimal balance       = (decimal)(rand.NextDouble() * 10000);
                decimal paymentAmount = balance / (20 * 12);
                decimal rate          = (decimal)(rand.NextDouble() % .2);

                portfolio.AddLoan(new Loan()
                {
                    Balance = balance, LoanNumber = loanNum, PaymentAmount = paymentAmount, Rate = rate
                });
            }
        }
Exemple #2
0
        public static void AddLoan(LoanPortfolio portfolio)
        {
            Console.Write("Loan Balance: ");
            decimal balance = decimal.Parse(Console.ReadLine());

            Console.Write("Monthly Payment: ");
            decimal payment = decimal.Parse(Console.ReadLine());

            Console.Write("Interest Rate: ");
            decimal rate = decimal.Parse(Console.ReadLine());

            Console.WriteLine("");

            portfolio.AddLoan(new Loan()
            {
                Balance = balance, Rate = rate / 100, LoanNumber = _nextLoanNumber++, PaymentAmount = payment
            });
        }