I am not sure how to fix this problem. I am trying to pause the display after the first 15 lines until the array ends.
/* Week 4 Individual
* Programmer: Melissa Snider
* Date: 4/6/2008
* Calculate the mortgage payment for 3 loans with an array
*/
package prg420.week4; // adds the package
import java.text.DecimalFormat; // Import the java. text for formating
import java.lang.Math; //Import the java math
class Calculator //creates and start this class
{
public void MortArray() //creates array
{
java.text.DecimalFormat df2 = new java.text.DecimalFormat(",###.00"); // formats numbers to display only two decimal places
// declare variables
double monPayment; // monthly payment
double monIntRate; // monthly interest rate
int months; // length of loan in months
double[][] mortgage =
{{200000, 84, 5.35, 0.0},
{200000, 180, 5.50, 0.0},
{200000, 360, 5.75, 0.0}};
//Using an array
for(int i=0; i<3; i++) // starts loop
{
months = (int) mortgage[i][1];
monIntRate = (mortgage[i][2]/12)/100;
monPayment = (mortgage[i][0]*monIntRate)/(1-Math.pow(1+monIntRate, -months));
System.out.println ("\n\nMortgage amount is \t" + df2.format(mortgage[i][0]));
System.out.println ("Terms of mortgage is \t " + mortgage[i][1] + "months");
System.out.println ("Interest rate is \t " + mortgage[i][2] + "%");
System.out.println ("Monthly mortgage payment \t$" + df2.format(monPayment));
}
}
}
public class MortCalculator
{
public static void main( String args[] ) //Create main method
{
Calculator CalculatorA = new Calculator(); //Create object with instance of MCalc
CalculatorA.MortArray(); //Call array
// these conditional statements cause the results to pause
if(term == 15)
{
term = 0;
try
{
Thread.sleep(5000); // pause to last five seconds
} //end thread
catch (InterruptedException e)
{
}
} // end if
else
{
term++;
} // end else
}
}
Help