4. Create the Loan Java file. The Loan file must be in your new project
mentioned above. It must be in a separate file from the Main class.
1. To create the new file, select menu File>New File. In the New File
dialog window, select the top choices (Categories: Java Classes; File
Types: Java Class), and then click the Next button. In the New Java Class
window, fill in the Class Name with Loan (without the quotes) and
make sure that the location and package is the same as for the Main file.
Then click the Finish button.
2. As a result, under Source Packages, you should now have the two
files listed within your package folder.
5. Write the code for the Loan class (file). You should follow the instructions listed
below carefully, since your Loan class must work with the Main class (file) provided to
you. You must use the Main class (file) to demonstrate that your Loan class works
correctly. The Loan class must include the following items:
a. Private member variable named borrowerName of type String.
b. Private member variable named loanId of type int.
c. Private member variable named propertyCost double.
d. Private member variable named downPayment of type double.
e. Private member variable named numberOfYears of type int.
f. Private member variable named annualInterestRate of type double.
g. Private DecimalFormat object to format monetary values and fixed decimal
numbers, as in previous exercises.
h. Public constructor that takes five parameters to initialize the member variables.
The order of the parameters must be: String nam, int id, double propCost, double
downPay, int numYears.
i. A public get method for each member variable. Naming convention is to
uppercase the firstletter of the member variable and then concatenate the word get
on the left end of the variable (e.g., getBorrowerName, getLoanId, getPropCost,
getDownPayment, getNumYears). Each get method takes no parameters and must
return the value of the corresponding variable.
j. A public calculateMonthlyPayment method that takes no parameters and
returns a value of type double. The returned value is the loans monthly payment,
computed by using the formula provided in a prior (3) lab. Do not add a member
variable for the payment.
k. A public toString method that takes no parameters and returns a string. The
string includes the values of all the member variables as well as the loans computed
monthly payment, with an explanatory label identifying each. All monetary values
must be formatted with a dollar sign and two digits to the right of the decimal point.
The returned string must not include any line breaks.
6. Compile, run, and debug your program.
a. When you compile your program, the Loan class (file) must be compiled first
because it is not dependent on any other classes (files).
b. The Main file is compiled second because it uses (is dependent on) the Loan
class.