I was wondering if there is a way to format the output of an array so that each indexed item has a discriptor and formatted in a certian way?
Example:
I have an array with 2 rows and 2 columns filled with numbers = double[][] numberArray = new double[2][2];
sample data
[0][0] = 1
[0][1] = 1
[1][0] = 2
[1][1] = 2
When I run my for loops my output statement is:
for (int i=0; i<ROWS; i++)
{
for (int j=0; j<COLUMNS; j++)
{
System.out.print(" " + numberArray[i][j]);
}
This will output something like this:
1.0 1.0
2.0 2.0
I would like to format the output to look like this:
Day 1 Earnings $ 1.00
Day 2 Earnings $ 2.00
If I try the System.out.printf(.......); I can only put one discriptor and one format for both columns. I would like to format each column seperately from each other.
Could you please point me in the right direction?
Thanks,
DS