Loan Calculator


 Design interface and implement functionalities for Loan calculator. Take Amount, No of installments and Rate of interest from the user. Also user can choose Early Pay option through a checkbox. Calculate installment amount using pmt() function. Do proper validation for inputs taken by the user.


Design:- 


Code:- 

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;
using Microsoft.VisualBasic;
using System.Threading.Tasks;

namespace Loan_Calculator
{
    public partial class frmloancalculator : Form
    {
        public frmloancalculator()
        {
            InitializeComponent();
        }

        private void lblloancalculator_Click(object sender, EventArgs e)
        {

        }

        private void btncalculate_Click(object sender, EventArgs e)
        {
            double p = Convert.ToDouble(txtenteramount.Text);
            double r = Convert.ToDouble(txtenterrate.Text); 
            double n = Convert.ToDouble(txtentertime.Text);
            double M_payment;
            double T_payment;
            r = r / 100 / 12;//for Monthly Payment
            n = n * 12;//convert into Months
            M_payment= (p*r*(Math.Pow((1+r),n)))/((Math.Pow((1+r),n))-1);
            T_payment = (M_payment * n) - p;
            txttotalpayment.Text = Convert.ToString(T_payment);

            txtmonthlypayment.Text=Convert.ToString(M_payment);
        }

        private void btnreseat_Click(object sender, EventArgs e)
        {
            txttotalpayment.Text = "";
            txtmonthlypayment.Text = "";
            txtentertime.Text = "";
            txtenterrate.Text = "";
            txtenteramount.Text = "";
        }

        private void btnexit_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void btnearlypaycalculate_Click(object sender, EventArgs e)
        {
            double p = Convert.ToDouble(txtenteramount.Text);
            double r = Convert.ToDouble(txtenterrate.Text);
            double n = Convert.ToDouble(txtentertime.Text);
            double monthly_rate = r / 1200;
            Double iamt;
            double FV=0;
            if (rbearlypay.Checked == true)
            {
                iamt = Financial.Pmt(monthly_rate,n,
                      -p, FV,
                        DueDate.BegOfPeriod); 
            }
            else
            {

                iamt = Financial.Pmt(monthly_rate, n,
                     -p, FV,
                       DueDate.EndOfPeriod);
            }
            txtpayment.Text=Convert.ToString(iamt);
        }
    }
}




No comments:

Post a Comment

Aarsh Prajapati

Welcome! Java Programs And Theory  Practical    Theory Java Basic Program Java Simple Program Array, Inheritance and Interface Program Packa...