-2

I need help into formating the output of an Java application on which I work.

The output should look like this(evrey line bellow coresponding category):

---------------------------------------------------
|Account number| Savings Balance| Checking Balance|
---------------------------------------------------
|an integer    | a double       |         a double|
---------------------------------------------------
|............  | .........      |      ...........|
---------------------------------------------------

What I have done:

System.out.println("|--------------| ---------------| ----------------|");
             System.out.println("|Account number| Savings balance| Checking balance|");
            for (int i=0; i<a.length; i++)
            {

            System.out.println("|"+a[i].getAccountNo()+"|"+a[i].getSavingBal()+"|"+a[i].getCheckingBal()+"|");
            System.out.println("|--------------| ---------------| ----------------|");

        }
            System.out.println("|--------------| ---------------| ----------------|");
Andrew Thompson
  • 163,965
  • 36
  • 203
  • 405
MariusBV
  • 1
  • 3

1 Answers1

0

u can use String.format() like

System.out.println(String.format("%03d %7s %7s %11s", val1, val2, val3, val4));