Ejemplo n.º 1
0
        public int CalcMonthsSaved(LoanObjectModel loan)
        {
            int    monthsRemaining  = loan.years;
            int    months           = loan.years;
            double principal        = loan.principal;
            double monthRate        = loan.rate;
            double payment          = loan.monthlyPayment;
            double principalPayment = 0;
            double interestPayment  = 0;
            double extra            = loan.extraPayment;

            for (int i = 0; i < months; i++)
            {
                interestPayment   = principal * monthRate;
                principalPayment  = payment - interestPayment;
                principalPayment += extra;
                principal        -= principalPayment;
                monthsRemaining--;

                if (principal < 0)
                {
                    break;
                }
            }
            monthsSaved = monthsRemaining;

            return(monthsRemaining);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// convert yearly interest to monthly interest
        /// </summary>
        /// <param name="loan"></param>
        /// <returns></returns>
        public double calcInterest(LoanObjectModel loan)
        {
            double interest         = 0;
            int    months           = loan.years;
            double principal        = loan.principal;
            double monthRate        = loan.rate;
            double payment          = loan.monthlyPayment;
            double principalPayment = 0;
            double interestPayment  = 0;
            double extra            = loan.extraPayment;

            if (loan.extraPayment > 0)
            {
                for (int i = 0; i < months; i++)
                {
                    interestPayment   = principal * monthRate;
                    principalPayment  = payment - interestPayment;
                    principalPayment += extra;
                    principal        -= principalPayment;
                    interest         += interestPayment;

                    if (principal < payment)
                    {
                        interest += principal * monthRate;
                        break;
                    }
                }
            }
            else
            {
                interest = loan.monthlyPayment * loan.years - loan.principal;
            }

            return(interest);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// get mortgage payment
        /// </summary>
        /// <param name="loan"></param>
        /// <returns></returns>
        public double MonthlyPayment(LoanObjectModel loan)
        {
            double intermediate;

            months               = SetMonths(loan.years);
            monthlyRate          = SetMonthlyInterest(loan.rate);
            loan.principal      -= loan.downPayment;
            monthlyRate         += 1;
            intermediate         = Math.Pow(monthlyRate, months);
            monthlyRate         -= 1;
            loan.monthlyPayment  = monthlyRate * intermediate;
            intermediate        -= 1;
            loan.monthlyPayment /= intermediate;
            loan.monthlyPayment *= loan.principal;
            loan.monthlyPayment += loan.interest_Utilities;
            return(loan.monthlyPayment);
        }
Ejemplo n.º 4
0
 public double TotalAmountToBePaid(LoanObjectModel loan)
 {
     moneySaved = monthsSaved * loan.monthlyPayment;
     return(moneySaved);
 }