Change request 4 - week 2 Assignment
Requestor: Ninfa Pendleton - Rapid City, SD
Description: Write the program in Java (with a graphical user interface) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage, the term of the mortgage, and the interest rate of the mortgage. Allow the user to loop back and enter new data or quit. Please insert comments in the program to document the program.
Version: 2.0.1
*/ import java.io.*; import java.text.DecimalFormat; import java.awt.*; import java.awt.event.*; import java.awt.Color; import java.awt.Graphics; import javax.swing.*; import java.applet.Applet; import java.util.*;
public class WK2MortCalcVer_2 …show more content…
} // Calculates data input from GUI public void clickCalculatePayment() { // GUI input double mortgageAmount = Double.parseDouble( mortgageAmountTextField.getText() ); double mortgageInterest = Double.parseDouble( mortgageInterestTextField.getText() ); int mortgageTerm = Integer.parseInt( mortgageTermTextField.getText() ); // new version of the loan mortgageLoan loan = new mortgageLoan( mortgageAmount, mortgageInterest, mortgageTerm ); // visual output to GUI based on user input response.setText( " Your Mortgage Loan Amount: " + dcm.format( mortgageAmount ) + "\n"); response.append( " Interest Rate: " + mortgageInterest + "\n" ); response.append( " Term of Mortgage Loan: " + ( mortgageTerm * 12 ) + " months\n" ); response.append( " Monthly Mortgage Payment: " + dcm.format( loan.mortgagePaymentCalculation() ) + "\n" ); } // new main public static void main( String[] args ) { WK2MortCalcVer_2 newloan = new WK2MortCalcVer_2(); // new instance of class }
}
class mortgageLoan
{
double mortgageAmount; double monthlyPayment; double mortgageInterest; //double monthyInterest = mortgageInterest/12; int