-
Notifications
You must be signed in to change notification settings - Fork 0
/
MortgageReport.java
37 lines (31 loc) · 1.4 KB
/
MortgageReport.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import java.text.NumberFormat;
public class MortgageReport {
private final static byte MONTHS_IN_YEAR = 12;
private MortgageCalculator calculator;
public MortgageReport(MortgageCalculator calculator){
this.calculator = calculator;
}
public void printMortgage(){
System.out.println();
System.out.println("MORTGAGE");
System.out.println("--------");
String mortgagePayment = NumberFormat.getCurrencyInstance().format(calculator.calculateMortgage());
System.out.println("Monthly Payment: " + mortgagePayment);
}
public void printPaymentSchedule(){
System.out.println();
System.out.println("PAYMENT SCHEDULE");
System.out.println("----------------");
for(short month=1; month<=(calculator.getTimePeriod()*MONTHS_IN_YEAR); month++){
double balance = calculator.calculateBalance(month);
System.out.println(NumberFormat.getCurrencyInstance().format(balance));
}
}
public void printInterest(){
double intersetPaid = (calculator.calculateMortgage() * calculator.getTimePeriod() * MONTHS_IN_YEAR) - calculator.getPrincipal();
System.out.println();
System.out.println("INTERSET PAID");
System.out.println("-------------");
System.out.println(NumberFormat.getCurrencyInstance().format(intersetPaid));
}
}