My assignement is to write a mortgage caclulator that displays x number of lines pauses then continues to dsiplay another x lines of data. Below is my code and I can not get it to work properly. It slowly prints the first 12 lines then displays everything else at once.
/**
* Mortgage Calculator
* Week 3 Individula assignment for Java Instructor- Troy
* @author Frank Tobin
*/
import java.text.DecimalFormat;
import java.lang.Math;
public class MortgageCalc {
/** The variables are defined in this section to be initialized later.*/
double lAmount;
double lTerm;
double lRate;
double lPayment;
double mRate;
double lYears;
double iPayment;
double pPayment;
double pNumber;
int linecount;
DecimalFormat money = new DecimalFormat("$#,#00.00");
public static void main(String args[]) {
MortgageCalc Mortg = new MortgageCalc();
Mortg.calculatePaymentAmount();
}
/** All of the variables are initialized in the following section along with the decimal format Intialized*/
public MortgageCalc() {
lAmount = 200000;
lTerm = 360.00;
lRate = 0.0575;
lPayment = 0;
lYears = lTerm/12;
pNumber = 0;
iPayment = 0;
pPayment = 0;
linecount = 12;
}
//First Calculated the interest rate per month then used in the Mortgage Calculator to determine monthly payments*/
public void calculatePaymentAmount() {
mRate = lRate/12;
lPayment = lAmount*(mRate*Math.pow(1+mRate,lTerm)/(Math.pow(1+mRate,lTerm)-1));
// Loop for amortization list
for (int count = 1; pNumber <= lTerm ; count++) {
// Calculations to determine amortization
iPayment = lAmount * mRate;
pPayment = lPayment - iPayment;
lAmount = lAmount - pPayment;
System.out.println(+pNumber + ". " + (money.format(lPayment))
+ "\t" + (money.format(lAmount))
+ " \t" + (money.format(pPayment)) + "\t\t"
+ (money.format(iPayment)) + "\n");
pNumber++;
if(linecount > 0)
{
linecount--;
try {
Thread.sleep(4500); // pause to last three seconds
}
catch (InterruptedException e) {}
}
}
}
}