Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Loan Payment Calculator (http://www.go4expert.com/forums/loan-payment-calculator-t26948/)

jenl2881 17Oct2011 08:39

Loan Payment Calculator
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:
Price  x (Interest Rate / 12)
  (1 – ( 1 + Interest Rate / 12 ) –Number  of Months)
                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;

masterwarner 8Nov2011 02:14

Re: Loan Payment Calculator
So what problem are you exactly facing ?

All times are GMT +5.5. The time now is 12:41.