Counters in FOR statements

My program prints out 360 lines. I need to print them out 20 at a time, pause, and ask the user if they want to continue. If the answer is yes, it would print the next 20. I already have the initial counter, for my calculations. Can I have two counters in my FOR statement? How would I do that?

Also, is there a better way to display $ values? I can't seem to get them to justify right, and I have all of the zeros in there.

//packages imported for class and method use

import java.io.*;

import java.util.Date;

import java.text.DecimalFormat;

import java.lang.Object;

import java.util.Formatter;

//class header

public class MortgageCalculator1

{

//method header

public static void main(String[] args)

{

Date currentDate = new Date(); //Date constructor

DecimalFormat decimalPlaces=new DecimalFormat(" $###,##0.00\t");//decimalconverter

DecimalFormat intPlaces=new DecimalFormat("000\t");

//declaring variables

int i;

final double balance = 200000;

final double monthlyInterest = .0575/12;

final double months = 360;

double payment = (balance*monthlyInterest)/(1-Math.pow(1+ monthlyInterest, -months));

double interestPaid;

double balancePaid;

double newBalance;

double previousBalance;

// Program Header

System.out.println();

System.out.println("\t\t\t\tMortage Calculator");

System.out.println("\t\t\t\tBy Jennifer Prince");

System.out.println("\t\t\t\tJava Programming");

System.out.println("\t\t\t\t" + currentDate);

System.out.println();

System.out.println("The monthly payment on" + decimalPlaces.format(balance) + " at 5.75% APR is "+ decimalPlaces.format(payment));

System.out.println();

System.out.println();

System.out.println("Installment\t\tPrevious Balance\tMonthly Payment\t\tInterest Paid\t\tPrinciple Paid\t\tNew Balance");

System.out.println();

System.out.println();

previousBalance = balance;

for(i=1; i<=months; i++){

interestPaid = monthlyInterest*previousBalance;

balancePaid = payment-interestPaid;

newBalance = previousBalance-balancePaid;

System.out.println("Payment " + intPlaces.format(i) + decimalPlaces.format(previousBalance) + decimalPlaces.format(payment) + decimalPlaces.format(interestPaid) + decimalPlaces.format(balancePaid) + decimalPlaces.format(newBalance));

previousBalance = newBalance;

}

//System.out.print("continue(y/n): ");

}//close method header

}//close class header

[2625 byte] By [princejlynna] at [2007-11-27 2:43:11]
# 1
It sounds like you want to nest two for loops. The inner one counts to 20 and asks if the user wants to continue. The outer one counts to 360 / 20 = 18.
jverda at 2007-7-12 3:08:32 > top of Java-index,Java Essentials,New To Java...
# 2
yes, I think that is what I would like to do......I tried putting an if statement in, but I need to do more than that, because it didn't do what I wanted it to. So, if I do the nested FOR loops, where would I put the second for?
princejlynna at 2007-7-12 3:08:32 > top of Java-index,Java Essentials,New To Java...