import java.math.*; import java.text.*; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; class MortgageCalculator4 { public static void main(String arguments[]) { //Program Variables using array double []terms = {84,180,360}; double []Rates = {0.0535, 0.055, 0.0575}; double loan; int i; double term, interestRate; //Temporary variables to make things generic and clearer DecimalFormat df = new DecimalFormat("$###,###.00"); //Formatting the output //for each term and Rate starting from the first location of each array terms[] and Rates[] for (loan = 200000, i=0;i=0){ //Show twenty lines/periods at a go, or until remaining balances reduces to 0 Balance = LoanAmount*(1+MonthlyInterestRate) - MonthlyPayment; //Calculation of Balance Interest = LoanAmount*MonthlyInterestRate; //Calculation of Interest //Now print using the round to two decimal places System.out.println(""+periods +"\t\t"+(Math.round(LoanAmount*100.00)/100.00)+"\t\t"+(Math.round(Interest*100.00)/100.00)+"\t\t"+(Math.round(Balance*100.00)/100.00)); LoanAmount = Balance; //Set the Principal for next round to the Balance of previous month periods++; i++; } System.out.println("Press Enter to continue.."); BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 1); String str = ""; try { str = br.readLine(); //hesitate or prompt for enter after screenfull } catch (IOException ioe) { System.out.println(ioe); } } } } //class MortgageCalculator4 ends here