Problem Summary Suppose you wanted to modify your Mortgage Calculator from Java programming assignment 3. You could:  Store all the previous data about one mortgage loan as data fields

Problem Summary Suppose you wanted to modify your Mortgage Calculator from Java programming assignment 3. You could:  Store all the previous data about one mortgage loan as data fields within an object  Add a mortgage loan identifier data field  Revise the calculation methods to be instance methods within the object’s class o NOTE: This will eliminate the need to pass the loan data into the methods via parameters. Since you will be modifying your Mortgage Calculator program from Java Assn 3, make sure you use your instructor’s feedback to fix any mistakes from Java Assn 3 before you submit Java Assn 4. Overview of Program This program will contain two classes, in two separate files within your project:  A new MortgageLoan class to define the data fields and methods for a MortgageLoan object, containing: o Six data field definitions for a MortgageLoan object o A constructor method to create a MortgageLoan object o Four setter methods to set the values for four of the data fields o Four getter methods to get the values of four of the data fields o An instance method to compute the monthly property tax. o An instance method to compute the monthly insurance premium. o An instance method to compute the monthly principle and interest loan payment.  The main MortageCalculator class, modified to define only 4 methods, containing: o A main method to display the program description, create an object, read the inputs from the user, and call the other methods. o A static method to display a description of what the program will do. o A static method to display loan details. o A static method to calculate and display the results of the program. Since there will be multiple files, the program will be submitted via a .zip file (see last page). Program Requirements Modify the program you wrote for Java Assn 3, as follows: 1. Define an additional Java class (File | New File | Java Class) named: MortgageLoan Within the MortgageLoan class, define the following private data fields to store properties about the mortgage loan:  loan identifier (String)  new!  home value  down payment (double value that will hold a whole number percent of home value, e.g. 10.0)  loan amount  length of loan (in whole years)  loan annual interest rate (floating point percentage, e.g. 4.5) Remember that all private data fields defined at the class-level can be accessed by any method within the same class (without parameter passing). Also within the new MortgageLoan class, you will define instance methods that can be used with an object of the MortgageLoan class, as follows:  Define a default constructor with no parameters that will create the object with the following initial data values set: Loan identifier set to “” (an empty String) Home value, loan amount, and interest rate all set to 0.0 Down payment set to 10% Loan length set to 30 years  Create setters for the following data fields: o Setter for loan identifier  Input parameters will be two Strings: the home buyer’s last name and zip code.  Use the built-in Java String methods to uppercase and extract the first 4 letters of the last name and concatenate them with the last 3 digits of the zip code to create the loan identifier.  Set the loan identifier data field to this value. o Setter for home value  Input parameter will be home value.  Set the home value data field to the parameter value. o Setter for loan amount  No parameters  Calculate the loan amount using the home value and the down payment percent data fields. Be sure to convert the down payment from whole number value to a value that can be used in a math formula.  Set the loan amount data field to the calculated value. o Setter for loan annual interest rate  Input parameter will be the annual interest rate.  Set the loan annual interest rate data field to the parameter value  Create getters for the following data fields in the MortgageLoan class: o loan identifier (String) o loan amount o length of loan (in years) o loan annual interest rate (percentage) Each of the getters should return the data field’s current value.  Move the calculation methods (methods 2 – 4) from Java Assn 3 from the MortgageCalculator class to the MortgageLoan class. Then modify them, so they can be used as instance methods in the new MortgageLoan class, as follows: o Eliminate the parameter lists from each method (parameters will no longer be necessary). o Keep all constants previously defined in the methods, except for the number of loan months defined in method 4.  Use the loan length data field from the object to calculate the number of months in the loan, instead of the previous constant value. o Modify the formulas to use the object data fields, instead of parameters. 2. Within the original MortgageCalculator class that contains the main method:  Make sure you deleted the old static calculation methods when you moved them to the MortgageLoan class.  Modify the main method to perform the following additional tasks (beyond Java Assn 3): o After displaying program description, create an object of the new MortgageLoan class type. o Prompt for (using descriptive prompts) and read:  the home buyer’s last name (you can assume there will be no spaces in the last name and it will contain at least 4 letters).  the home buyer’s zip code o Same as before, prompt for (using descriptive prompts) and read the home value and the annual interest rate. Sample Input o Use the setters to set the values in the following data fields of the object:  Set the values for the loan identifier and home value fields first.  Then set the values for the loan amount and loan annual interest rate. Be sure to pass any necessary parameters to the setters. After setting all the data fields, display a couple of blank lines to separate input and output. o Call the two static display methods:  A new method to display the loan details (details below)  A revised method to calculate and display the loan payment information (details below) The main method code should not calculate any results itself, nor display any loan details or loan payment information. All this should be done from within the two display methods, after being called from the main method code.  The new static method to display the loan details will: o Have only one parameter: the mortgage loan object o Use the getters to get and display the loan’s information (loan identifier, loan amount, loan length, and annual percentage rate), formatted as shown in the Sample Output below:  The loan information is displayed under the header “Loan Details” and be indented.  The loan amount should be displayed to 2 decimal places  The loan length should be displayed in years  The annual percentage rate should be displayed to 3 decimal places  All values should line up with each other on the right  The static method to calculate and display results from Assn 3 will need to be modified to use the new mortgage loan object. It will: o Have only one parameter: a mortgage loan object o Send messages to the loan object to compute the three parts of the monthly mortgage payment, by calling each of the calculation instance methods.  Save the result returned from each calculation method in separate local variables. o As in Java Assn 3 display the results:  The loan payment figures should be displayed under the header “Monthly Mortgage Payment”, and be indented.  Display each of the calculated values (the three parts of the mortgage payment) to 2 decimal places, lined up on the decimal points.  Calculate and display the total monthly mortgage payment. Line all figures up on the right, to the same place as the figures that were output from the loan details method, as shown below. Output from new “loan details” method Output from revised “calculate and display results” method Loan Details Loan identifier SMIT221 Loan amount 199999.80 Loan length 30 years Annual interest rate 4.250% Monthly Mortgage Payment Monthly Taxes 102.08 Monthly Insurance 91.00 Monthly Principle & Interest 983.88 ——– Total Monthly Mortgage Payment 1176.96 WARNING: The methods must be implemented exactly as specified in these requirements. If your program produces correct output, but you did not implement the methods as specified (with correct parameter passing and return values), you will lose a significant number of points.

Do you need us to help you on this or any other assignment?


Make an Order Now