Question
Need some help on the following problem. Write a class MortgageCalculator that extends the FinancialCalculator class. The compute method of this class prints out the
Need some help on the following problem.
Write a class MortgageCalculator that extends the FinancialCalculator class. The compute method of this class prints out the total interest paid on a mortgage. The monthly payment is computed using this formula:
Monthy payment = Axr/n divided by 1 -[1/(1+r/n)nT]
where A is the mortgage amount, r is the interest rate, n is the number of payments in a year, and T is the term of the mortgage in years. The total interest paid is calculated by taking the product of the monthly payment, the number of payments in a year n, and the term T. Write a program to test this class.
The FinancialCalculator class:
package inheritance; import java.util.*;
public abstract class FinancialCalculator { // calendar protected Calendar calendar;
// returns the number of days for the current month set on calendar protected int getDaysInMonth() { return calendar.getActualMaximum(Calendar.DAY_OF_MONTH); }
// returns the number of days in the current year set on calendar protected int getDaysInYear() { return calendar.getActualMaximum(Calendar.DAY_OF_YEAR); }
protected abstract void getUserInput(); protected abstract void compute(); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started