Explore BrainMass

Modified Mortgage Calculator Problem


Write an Exception class called MortgageInputexception.java. this class will inherit from the Exception.class in the java API. The exception should be packaged in the src.calculator.gui package.

Modify MortgagedisplayGui.java to include a function called is ValidRate(String testValue) is Valid Term(String testValue) is ValidLoanAmount(String testValue) that will interrogate an input value for each of the entries, rate, term and loan amount. This function will throw the MortgageInputException if the entry is not valid. Use the String manipulation functions to determine if the content is appropriate. That is, the entry does not contain special characters and letters, and for rate does meet the format the calculator requires in order to use the rate in the equations.

Modify MortgageDisplayGui.java to try and catch for this MortgageInputException and upon error, report the Error to the user via a JoptionPane using the ERROR_MESSAGE and DEFAULT_OPTION constants provided by the JoptionPane class.

The new validation functions should throw the exception MortgageInputException.

Include in MortgagedisplayGui.java:

public static final String Rate_Error_MSG;
public static final String Amount_Error_MSG;
public static final String Term_Error_MSG;

private void calculate() {

isValidRate(in testValue : String) : double
is ValidLoanAmount(in testValue : String) : double
is ValidTerm(in testValue : String) : double
displayError(in message : String)

© BrainMass Inc. brainmass.com July 15, 2018, 7:23 pm ad1c9bdddf


Solution Summary

The modified mortgage calculator problems are analyzed. The string manipulation functions to determine if the content is appropriate is determined.