I have created a 2D array and want to print the output. I want to label the columns and rows. I have labeled the rows. but I can not figure out how to label the columns. Something link this:
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
Like I said I have the rows and the *, but how do I get the A b c labels on the columns.
for(int i = 1; i < 13; i++)
{
System.out.print("Row " + i + " " );
for(int j = 0; j < 6; j++)
{
System.out.print(seats[i][j] + " ");
}
System.out.println(); //for spacing
}
assuming you know how many columns you have and it’s less than 26, you could add this on to the start of your code…
going past 26 is a little more complex, let me know if you need that.