Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Instructions Write a program to estimate monthly payments in a car loan consider

ID: 3722367 • Letter: I

Question

Instructions Write a program to estimate monthly payments in a car loan considering the listed assumptions: If A dollars are borrowed atr% interest compounded monthly to purchase a car with monthly payments for n years, then the monthly payment is given by the formula -12n Where i-1200, write a program that calculates the monthly payment after the user gives the amount of the loan, interest rate, and number of years. The figure below shows that monthly payments of $234.23 are required to pay off a 5-year loan of $12,000 at 6.4% interest. (Hint: make the calculation for the interest "i rate first. Then, do the monthly payment calculation paying close attention to the use of nested parentheses, if you use them.) Car Loan Amount of loan: 12000 Interest rate (2): 164 Number of years: 5 Calculate Monthly Payment Monthly payment: $234.23

Explanation / Answer

this is java swing program as per ur requirement

only contain one java file ( Interest.java )

run this file after java instalation

Interest.java

------------------------

package com.sorting;

import java.awt.FlowLayout;

import java.awt.event.ActionEvent;

import java.awt.event.ActionListener;

import java.text.DecimalFormat;

import javax.swing.JButton;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JTextField;

public class Interest extends JFrame implements ActionListener

{

JLabel l1,l2,l3,l4;

JButton b1;

JTextField t1,t2,t3,t4;

Interest()

{

l1=new JLabel("Amount Of Loan");

l2=new JLabel("Interest Rate (%)");

l3=new JLabel("Number Of Years");

b1=new JButton("Calculate Monthly Payment");

l4=new JLabel("Monthly Payment");

  

  

t1=new JTextField(10);

t2=new JTextField(10);

t3=new JTextField(10);

t4=new JTextField(10);

  

add(l1);

add(t1);

add(l2);

add(t2);

add(l3);

add(t3);

add(b1);

add(l4);

add(t4);

  

b1.addActionListener(this);

  

setSize(900,900);

setLayout(new FlowLayout());

setTitle("Car Loan");

}

public void actionPerformed(ActionEvent ae)

{

int loanAmount,termInYears;

double interestRate;

if(ae.getSource()==b1)

{

loanAmount=Integer.parseInt(t1.getText());

interestRate=Double.parseDouble(t2.getText());

termInYears=Integer.parseInt(t3.getText());

double value=Interest.calculateMonthlyPayment(loanAmount, termInYears, interestRate);

DecimalFormat df = new DecimalFormat("#.##");   

value = Double.valueOf(df.format(value));

t4.setText("$"+String.valueOf(value));

}

  

  

}

public static void main(String args[])

{

Interest a=new Interest();

a.setVisible(true);

a.setLocation(200,200);

  

}

public static double calculateMonthlyPayment(

int loanAmount, int termInYears, double interestRate) {

// Convert interest rate into a decimal

// eg. 6.5% = 0.065

interestRate /= 100.0;

// Monthly interest rate

// is the yearly rate divided by 12

double monthlyRate = interestRate / 12.0;

// The length of the term in months

// is the number of years times 12

int termInMonths = termInYears * 12;

// Calculate the monthly payment

// Typically this formula is provided so

// we won't go into the details

// The Math.pow() method is used calculate values raised to a power

double monthlyPayment =

(loanAmount*monthlyRate) /

(1-Math.pow(1+monthlyRate, -termInMonths));

return monthlyPayment;

}

}