Пример #1
0
        public void TotalMoneyPaidTest()
        {
            PayoffModel   model = new PayoffModel(259000, 4, 30, 0, 1236.51);
            TotalInterest save  = new TotalInterest(model);
            double        total = save.Algorithm();

            Assert.Equal(445143.60, total);
        }
Пример #2
0
        public void TotalMoneySavedTest()
        {
            PayoffModel   model = new PayoffModel(259000, 4, 30, 25, 1236.51);
            TotalInterest save  = new TotalInterest(model);
            double        total = save.Algorithm();

            Assert.Equal(16074.63, model.TotalMoneySaved);
        }
Пример #3
0
 public override string ToString()
 {
     return($"{Term} months (effective {AnnualPercentageRate}, nominal {NominalRate}): monthly {MonthlyPayment.ToString()}, total {TotalCost.ToString()}, interest {TotalInterest.ToString()}");
 }
Пример #4
0
        private void calculateBTN_Click(object sender, EventArgs e)
        {
            try
            {
                //declaring variables
                double PurchasePrice, DownPymt, Rate, MonthlyPymt, LoanAmt, Percent, TotalInterest;

                int Term;


                //parsing text
                PurchasePrice = double.Parse(inPurchasePriceTB.Text);

                DownPymt = double.Parse(inDownPymtTB.Text);

                Rate = double.Parse(rateTB.Text) / 100;

                Term = int.Parse(termTB.Text);

                Percent = double.Parse(inDownPymtTB.Text) / 100;



                //Checking Percent of purchase price or dollar value
                if (percentRB.Checked)
                {
                    DownPymt = PurchasePrice * Percent;
                }
                else if (dollarsRB.Checked)
                {
                    DownPymt = double.Parse(inDownPymtTB.Text);
                }

                // checking Years or Months
                if (yearsRB.Checked)
                {
                    Term = Term * 12;
                }
                else if (monthRB.Checked)
                {
                    Term = int.Parse(termTB.Text);
                }

                // assigning formula variables


                double interest = Rate / 12;
                LoanAmt = PurchasePrice - DownPymt;

                MonthlyPymt = LoanAmt * ((interest * (Math.Pow(1 + interest, Term))) /
                                         (Math.Pow(1 + interest, Term) - 1));

                TotalInterest = (MonthlyPymt * Term) - LoanAmt;

                double totalAmtPaid = MonthlyPymt * Term;

                // Display the answers
                loanAmtTB.Text = LoanAmt.ToString();

                monthlyPymtTB.Text = MonthlyPymt.ToString("n2");

                totalInterestPaidTB.Text = TotalInterest.ToString("n2");

                totalAmtPaidTB.Text = totalAmtPaid.ToString("n2");
            }
            catch (Exception)
            {
                MessageBox.Show("Something is WRONG with your figures");
            }
        }