1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Loan Payment Calculator

Discussion in 'C#' started by jenl2881, Oct 17, 2011.

  1. jenl2881

    jenl2881 New Member

    Oct 17, 2011
    Likes Received:
    Trophy Points:
    I need to make a Car Loan Payment calculator where the user enters the price of the car, the current interest rate, the number of months the vehicle will be financed for and clicks Calculate. I am assuming the user enters valid informatino


     ·         Code a private method named calculateTotalInterest that calculates the total interest paid on the car and returns it as a decimal value. Monthly interest is calculated as (Price * Interest Rate)  / 12. This method should accept the following arguments:
                 price of car As Decimal
             The value entered for the Price of   Car
                 interest rate As Decimal
             The value entered for the Interest   Rate
                 number of months As Integer
             The value entered for the Number   of Months
                 monthly payment As Decimal
             The value calculated for Monthly   Payments:
       [CENTER][CENTER]Price   x (Interest Rate / 12)
      (1 – ( 1 + Interest Rate / 12 ) –Number   of Months)[/CENTER][/CENTER]
            ·         The results for Monthly Payment, Total Interest Paid, and Total Paid should be formatted as currency and displayed in the appropriate controls on the form
    When I try to run it (I am using Visual Studios) it hangs up at the payment calculation. Any help is GREATLY appreciated.
    This is what I have so far:
     using System;
      using System.Collections.Generic;
      using System.ComponentModel;
      using System.Data;
      using System.Drawing;
      using System.Linq;
      using System.Text;
      using System.Windows.Forms;
      namespace _549_LargeJ_Exam01
          public partial class Form1 : Form
              public Form1()
              private void btnExit_Click(object sender, EventArgs e)
              private void btnCalculate_Click(object sender, EventArgs e)
                  // declare variable
                  double months = Convert.ToDouble(txtMonths.Text);
                  double intrate = Convert.ToDouble(txtIntRate.Text);
                  double price = Convert.ToDouble(txtPrice.Text);
                  double payment = Convert.ToDouble(txtPayment.Text);
                  double intpaid = Convert.ToDouble(txtIntPaid.Text);
                  double totalpaid = Convert.ToDouble(txtTotalPaid.Text);
                  // conversion of text box values
                  // Calculations
                  payment = (price * (intrate/12))/(1 - (Math.Pow((1+intrate/12), months)));
                  totalpaid = intpaid+(months*payment);
                  intpaid = this.CalculateTotalInterest(price, intrate);
                  // display output
                  txtPayment.Text = payment.ToString("c");
                  txtIntPaid.Text = intpaid.ToString("c");
                  txtTotalPaid.Text = totalpaid.ToString("c");
                  private double CalculateTotalInterest(double p, double i)
                      return (p * i)/12;
    Last edited by a moderator: Oct 17, 2011
  2. masterwarner

    masterwarner New Member

    Nov 7, 2011
    Likes Received:
    Trophy Points:
    So what problem are you exactly facing ?

Share This Page