| Author |
help me pause and continue my program
|
Tami Hart
Greenhorn
Joined: Jun 09, 2004
Posts: 7
|
|
my instrutions are to calculate a $200000 mortgage at 5.75 interest over 30 years. I have to show the balance of the loan after each payment. I can get the program to do all the payments but I can not get it to pause after 10 payments then continue till all the payments have been displayed. or even possibly make 3 rows of 10 payments so the balances are on one page here is my program: import java.io.*; import java.text.NumberFormat; class Mortg3ab { public static void main(String[] arguments) { int p = 200000; int n = 360; double j =.0575/12; double i = 220172.46; double m = p * (j/(1-(Math.pow((1+j),-n)))); double bal = p - m; NumberFormat currency = NumberFormat.getCurrencyInstance(); String Beg = "^^^***^^^***Morgage Calculator***^^^***^^^"; System.out.println(Beg); System.out.println("Inital Mortgage " +p); System.out.println("Length of Loan in years 30 or 360 months"); System.out.println("Fixed Interest is 5.75 Percent"); System.out.print("Your monthly payment is "); System.out.println(currency.format(m)); System.out.println("The amount remaining on the balance of the loan after each payment is "); System.out.println(currency.format(bal)); for (int count = 1; count <=359; count++){ int rm = 1 * count; double bl = p + i - m; double rmbal = rm + (bl -(m * count)); System.out.println("\n"); System.out.print(rm + ".\t"); System.out.print(currency.format(rmbal)); } } }
|
 |
Pavel Kubal
Ranch Hand
Joined: Mar 13, 2004
Posts: 356
|
|
|
I you want to pause program for some time try Thread.sleep() method.
|
 |
John Smith
Ranch Hand
Joined: Oct 08, 2001
Posts: 2937
|
|
I can get the program to do all the payments but I can not get it to pause after 10 payments then continue till all the payments have been displayed. You may want to go a step further -- throw a simple Swing front end with a text area and a scroller so that all payments can be viewed easily. That will impress your professor and, more importantly, give you a start in Swing.
|
 |
Dirk Schreckmann
Sheriff
Joined: Dec 10, 2001
Posts: 7023
|
|
I can not get it to pause after 10 payments Perhaps you want to add a simple if statement inside the for look that prompts the user to press enter to continue after every 10 results have been displayed.
|
[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
|
 |
 |
|
|
subject: help me pause and continue my program
|
|
|