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();
}
package inheritance;
import java.text.DecimalFormat;
import java.util.*;
//Base class FinancialCalculator
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);
}
//abstract methods getuser and compute declaration
protected abstract void getUserInput();
protected abstract void compute();
}
//Derived class MortgageCalculator extended from
FinancialCalculator
class MortgageCalculator extends FinancialCalculator
{
private static DecimalFormat df2 = new DecimalFormat("#.##");//this
is the formate to show only two decimal values after decimal
point
double A;//the mortgage amount
double r;//the interest rate
double n;//the number of payments in a year
double T;//the term of the mortgage in years
@Override
protected void getUserInput() {//get user methode Definition
Scanner input=new Scanner(System.in);//Scanner class object to get
inputs from user
System.out.println("\nEnter the Mortgage Amount: ");
A=input.nextDouble();//take Amount from user
System.out.println("\nEnter the Interest Rate: ");
r=input.nextDouble();//interest from user
System.out.println("\nEnter the Number of Payments in a Year:
");
n=input.nextDouble();//payments in a year in n
System.out.println("\nEnter the Term of the Mortgage in Years:
");
T=input.nextDouble();
compute();//after taking all the inputs from user we will call the
compute methode
}
@Override
protected void compute() {//compute methode definition
//according to formula's
double Monthy_payment = ((A*r)/n)/(1-(1/(1+r/n)*n)*T);//Calculate
payment of month
double total_interest_paid= Monthy_payment*n*T;//calculate interest
rate
System.out.println("\n\nTotal_Interest_Paid:
"+df2.format(total_interest_paid));//shows the output as interest
rate
}
}
public class Inheritance {
public static void main(String[] args) {
MortgageCalculator object=new MortgageCalculator();//creat
MortgageCalculator object to access methods
object.getUserInput();//call the userinputs funtion to perform its
functionality
}
}

PLEASE GIVE A THUMBS UP!!! DONT GIVE A THUMBS DOWN IF YOU HAVE ANY QUERY SO COMMENT DOWN I WILL CLEAR IT FOR YOU
Need some help on the following problem. Write a class MortgageCalculator that extends the FinancialCalculator class....
C++ problem 11-6 In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class dateType so that it can perform the following operations on a date, in addition to the operations already defined: Set the month. Set the day. Set the year. Return the month. Return the day. Return the year. Test whether the year is a leap year. Return the number of days in...
Write a class named Octagon (Octagon.java) that extends the following abstract GeometricObject class and implements the Comparable and Cloneable interfaces. //GeometricObject.java: The abstract GeometricObject class public abstract class GeometricObject { private String color = "white"; private boolean filled; private java.util.Date dateCreated; /** Construct a default geometric object */ protected GeometricObject() { dateCreated = new java.util.Date(); } /** Construct a geometric object with color and filled value */ protected GeometricObject(String color, boolean filled) { dateCreated = new java.util.Date(); this.color = color;...
Copy the program AmusementRide.java to your computer and add your own class that extends class AmusementRide. Note: AmusementRide.java contains two classes (class FerrisWheel and class RollerCoaster) that provide examples for the class you must create. Your class must include the following. Implementations for all of the abstract methods defined in abstract class AmusementRide. At least one static class variable and at least one instance variable that are not defined in abstract class AmusementRide. Override the inherited repair() method following the...
Java Programming: Hi, I need help Modifying my code that will throw an IllegalArgumentException. for the following data entry error conditions: A number less than 1 or greater than 12 has been entered for the month A negative integer has been entered for the year utilizes a try and catch clause to display an appropriate message when either of these data entry errors exceptions occur. Thank you let me know if you need more info import java.util.*; //Class definition public...
I need some help with some homework questions. How would I implement the to-do's? ----------------------------------------------------------------------------------------------------------------------------------------------------------- AbstractArrayHeap.Java package structures; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.NoSuchElementException; public abstract class AbstractArrayHeap<P, V> { protected final ArrayList<Entry<P, V>> heap; protected final Comparator<P> comparator; protected AbstractArrayHeap(Comparator<P> comparator) { if (comparator == null) { throw new NullPointerException(); } this.comparator = comparator; heap = new ArrayList<Entry<P, V>>(); } public final AbstractArrayHeap<P, V> add(P priority, V value) { if (priority == null || value...
Need Help....Java
MyProgram.java: public class MyProgram { public static void main(String[] args) { } } House.java: public class House { private String address; private double cost; private double interst; private int mortgageTime; private double monthPayment; } As you consider your life before you, one thing you may consider is buying a house in the future. In this assignment, you will explore concepts of this amazing opportunity and create a program that may be of benefit to you in the future!...
abstract class Exp { abstract void print(); abstract int eval(); } class ConstExp extends Exp { private int value; ConstExp(int v) { value = v; } void print() { System.out.print(value); } int eval() { return value; } } class BinaryExp extends Exp { private Exp arg1; private Exp arg2; private char op; BinaryExp(char op, Exp arg1, Exp arg2) { this.op = op; this.arg1 = arg1; this.arg2 = arg2; } void print() { System.out.print("("); arg1.print(); System.out.print(" " + op + "...
I have most of the code for this assignment but need some help getting the rest. Go to bottom to see what I have. Please help me figure out the foreach loops and the put() statement. In this assignment, you will be using a new data structure, HashMaps, to repeat Assignment 8.3. Main Method (5 points) Declare and initialize an HashMap with values of type of type Employee, and keys of type integer. In a while loop, keep initializing objects...
Please create a C++ class called myDate. It should have the following operations: myDate() – default constructor. This will set the date to May 10, 1959. myDate(int M, int D, int Y) – overloaded constructor. This will set the date to the values passed in through the parameter list represented by Month, Day and Year. void display() – display the date in the following format (May 11, 1959) Do NOT print a linefeed after the date. void incrDate(int N) –...
a derived class from Organism. You must complete the constructors, and the method definitions that were abstract methods in Organism. /** Organism.java * Definition for the Organism base class. * Each organism has a reference back to the World object so it can move * itself about in the world. */ public abstract class Organism { protected int x, y; // Position in the world protected boolean moved; // boolean to indicate if moved this turn ...