hello, what I need to do is have the program break when the display goes off the screen and then continue. I'm exploring "break" options but it seems that break wants to use a paramater like value I need to pause after say 30 threads are displayed. Hope someone can help...

import java.text.*;
import java.io.*;

// declares the class

public class MortCalc
{
 public static void main(String[] args)
 {
	//declare and construct variables
	int LoanAmt, Terms, N;
	double Rate;
	double r;
	double s;
	double MPayAmt = 0.00;
	double NLoanAmt;
	double Mint;
	double MPrinc;
	DecimalFormat monetary = new DecimalFormat("$###,###.##");

	LoanAmt = 200000;
	Terms = 30;
	Rate = 5.75;



	// Calculations
	r = Rate / 100 / 12;     // is the monthly interest rate calculation
	s = 1 + r; 			     // this is adding one onto r to effectively calculate Math.pow
	N = 360;		     // N is used for Number of monthly payments which is 360
	MPayAmt = (r / (1 - Math.pow(s,-N))) * LoanAmt;	// calculates payment, formula retrieved from http://www.financialone.com/mortgages/mortcalcs
    NLoanAmt = (LoanAmt - (MPayAmt - (LoanAmt * r)));   // calculates new loan balance amount

	 System.out.println();
	 System.out.println("McBride Financial Services Mortgage Payment Calculator");
	 System.out.println();
	 System.out.println();
	 System.out.println("Clients Loan amount: $" + LoanAmt + ".00");	// Displays loan amount
	 System.out.println();
	 System.out.println("Terms of the Loan: " + Terms + " years");		// Displays length of loan
	 System.out.println();
	 System.out.println("Interest Rate: " + Rate + "%"); 				// Display interest rate
	 System.out.println();
	 System.out.println("Clients Monthly payment amount: " + (monetary.format(MPayAmt) + "."));	// Display Monthly Payment Amount
	 System.out.println();

     for (int mpi =1; mpi<=N; mpi++) { // months of payment being decrimented start counter
     NLoanAmt = (NLoanAmt - (MPayAmt - (NLoanAmt * r)));  //calculates new loan balance amount
	 Mint = (NLoanAmt * r);   // calculates interest for 1 payment
     MPrinc = (MPayAmt - (NLoanAmt * r));  // calculates the principle for 1 payment
     System.out.println("New balance is: " + (monetary.format(NLoanAmt)) );  // display new balance
     System.out.println("Interest paid is " + (monetary.format(Mint)) );  // displays interest paid for this payment


     try
     {
		 Thread.sleep(100);  // makes a thread sleep for 10th of a second
	 }
	 catch (InterruptedException e)  // starts it back up
	 {}
	 }

 }


}

I don't understand your description. You want to "break" after a parameter like value is displayed? What? And how can you do something after 30 threads, when you only have one thread running in your program?

I don't understand your description. You want to "break" after a parameter like value is displayed? What? And how can you do something after 30 threads, when you only have one thread running in your program?

currenty the program displays 2 lines for 1 month of mortgage payment - 720 threads displayed (360 for balance, 360 for interest) before the loop ends. what I am trying to do is pause the display after say 24 months (48 threads) and then continue until the screen fills up again and pause.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.