MortgagePayments.cs

Posted by Jiltin     16 May, 2008    287 views   

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace MortgagePayments
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, System.EventArgs e)
{
double principal;     // total mortgage loan
double interestPerc;  // percent annual interest
double interestRate;  // monthly interest rate
double years;         // years to pay
double paymentNum;    // number of months to pay
double paymentVal;    // value of monthly payment
String fstr;

this.label4.Text = “”;
principal = double.Parse(this.textBox1.Text);
interestPerc = double.Parse(this.textBox2.Text);
interestRate = interestPerc / (100 * 12);
years = double.Parse(this.textBox3.Text);
paymentNum = years * 12;

paymentVal = principal * (interestRate / (1 – Math.Pow((1 + interestRate), (-paymentNum))));

fstr = String.Format(”Principal Loan: {0:C}\n”, principal);
this.label4.Text += fstr;
this.label4.Text += “Interest (%)  : ” + interestPerc + ‘\n’;
this.label4.Text += “Years to pay  : ” + years + ‘\n’;
this.label4.Text += “Months to pay : ” + paymentNum + ‘\n’;
fstr = String.Format(”Monthly pay   : {0:C}\n”, paymentVal);
this.label4.Text += fstr;
fstr = String.Format(”Total pay     : {0:C}\n”, paymentVal * paymentNum);
this.label4.Text += fstr;
}
}
}

Post to Twitter  Post to Delicious  Post to Digg    Post to StumbleUpon

Categories : Mortgage Pay Tags :

Comments

No comments yet.


Leave a comment

(required)

(required)