Mod 1. Modify the calculatePayment method. Modify the code for the method named
calculatePayment so that it meets the following specifications: The calculatePayment method must:
a. Take four parameters as input: (1) property cost (type double), (2) down payment (type
double), and (3) number of years (integer), and (4) type of property (type char).
b. Return a result of type double, namely the calculated payment for the month.
c. This method does not actually calculate the payment, but instead calls the appropriate
method depending on the type of property. The payment is computed by the called method as
described in the next numbered item below.
d. Depending on the type of property, the calculatePayment method must call the correct
method to compute the payment for the property:
i. If the property is Residential, call the method named
computeResidentialPayment. Pass the cost, down payment, and number of
years to this method.
ii. If the property is Commercial, call the method named
computeCommercialPayment. Pass the cost, down payment, and number of
years to this method.
iii. If the property is Agricultural, call the method named
computeAgriculturalPayment. Pass cost, down payment, and number of years to
this called method.
4. Mod 2. Implement the method for Residential payment calculation: Write the code for the
method named computeResidentialPayment. Place this method definition code below the main
method of the existing program class. This method must:
a. Include modifier static in the method header.
b. Take two parameters of type double: (1) cost and (2) down payment; One parameter type
integer: number of years.
c. Return a result of type double, namely the calculated payment for the month.
d. The residential annual interest rate is currently 5.75%. However, if the down payment is less
than 20% of the cost, the residential interest rate is 6.75%
e. Declare a local variable annual interest rate and assign the appropriate interest rate.
f. Calculate payment by calling the computeMonthlyPayment method. Pass the loan amount,
the annual interest rate, and the number of years to this method.
5. Mod 3. Implement the method for Commercial payment calculation: Write the code for the
method named computeCommercialPayment. Place this method definition code below the main
method of the existing program class. This method must:
a. Include modifier static in the method header.
b. Take two parameters of type double: (1) cost and (2) down payment. One parameter type
integer: number of years.
c. Return a result of type double, namely the calculated payment for the month.
d. The commercial annual interest rate is currently 8.6%. However, if the down payment is less
than 30% of the cost, the residential interest rate is 9.6%
e. Declare a local variable annual interest rate and assign the appropriate interest rate.
f. Calculate payment by calling the computeMonthlyPayment method. Pass the loan amount,
the annual interest rate, and the number of years to this method.
6. Mod 4. Implement the method for Agricultural payment calculation: Write the code for
the method named computeAgriculturalPayment. Place this method definition code below the
main method of the existing program class. This method must:
a. Include modifier static in the method header.
b. Take two parameters of type double: (1) cost and (2) down payment. One parameter type
integer: number of years.
c. Return a result of type double, namely the calculated payment for the month.
d. The Agricultural annual interest rate is 5.25%. However , if the down payment is less than 10%
of the cost, the agricultural interest rate is 6.25%.
e. Declare a local variable annual interest rate and assign the appropriate interest rate.
f. Calculate payment by calling the computeMonthlyPayment method. Pass the loan amount,
the annual interest rate, and the number of years to this method.
7. Mod 5. Implement the method for computing the monthly payment. Write the code for the
method computeMonthlyPayment method. The formula is in the original code given and should
have been commented out in part A of this lab. Just in case:
// Calculate monthly payment
// Change the annual interest rate to a decimal (/100) and a monthly rate (/12)
monthlyPayment = loanAmount * (annualInterestRate/1200) /
(1 - 1 / Math.pow(1 + (annualInterestRate/1200), numberOfYears * 12));
This method has parameters for loan amount, the annual interest rate, and the number of years to
this method. The method returns the monthlyPayment.
8. Mod 6. Implement the method for computing the total amount that is paid to the lender
for the loan. This method computeTotalPayment has parameters monthly payment and number
of years. The total amount paid is returned.
9. Mod 7. Display information on all properties. Your program must display all the information
on all the properties, one property per two lines. For each property, the displayed information
must include the following on one line, with each item labeled:
a. The cost of the property.
b. The down payment.
c. The number of years.
d. The type of property (Residential, Commercial, Agricultural).
e. The calculated monthly payment (which depends on the type of property).
Next line:
f. The total amount paid back for the loan.
10. Mod 8. Continue to display all the information on all properties during each pass
through loop. The program must continue to display the output string in a JOptionPane popup dialog
window during each pass through the loop. The information on each property must include the
property type, cost, loan amount, number of years, computed payment, and total amount paid. The
output display must include the formatting as specified in Lab 3-A, and the full name of the property
type as in Lab 3-A. The number of lines will grow as additional properties are added by the user.