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

Java GUI for Mortgage Problem Return to the mortgage problem from lab six. This

ID: 3719404 • Letter: J

Question

Java

GUI for Mortgage Problem Return to the mortgage problem from lab six. This time having the user enter the values into text boxes, rather than at the command line. To compute the monthly payment (M) for a mortgage we need the user to provide: P the principal of the loan rthe annual interest percentage (assume they give this as a percent value between 1 and 10) N the number of years for the mortgage (usually 15 or 30 years) We will use this input to compute: .the monthly interest rate (divide the annual interest rate by 1200) n the total number of payments (12*N) D the discount factor The monthly payment will be P/D Write a function that takes in P, r, and N and returns the monthly payment. In the main have the user enter values for P, r, and N. Have the program output their monthly payment.

Explanation / Answer

import javax.swing.JFrame;

import javax.swing.JOptionPane;

public class Driver {

public static void main(String[] args) {

double p, r, N;

JFrame f;  

f = new JFrame();

p = Double.parseDouble(JOptionPane.showInputDialog(f,"Enter P"));  

r = Double.parseDouble(JOptionPane.showInputDialog(f,"Enter R"));

N = Double.parseDouble(JOptionPane.showInputDialog(f,"Enter N"));

double i = r / 1200;

double n = 12 * N;

double D = (Math.pow((1 + i), n) - 1) / i * (Math.pow((1 + i), n));

double monthlyInstallement = (p / D);

JOptionPane.showMessageDialog(f, "Monthly payment is " + String.valueOf(monthlyInstallement));  

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote