Try:
Code:
class multiplication
{
public static void main(String[]args)
{
System.out.println("\n\tMultiplication Table\n");
System.out.print(" ");
for(int j = 1; j <= 12; j++)
{
System.out.print(" " + j);
}
System.out.println();
for(int i = 1; i <= 12; i++)
{
System.out.print(" " + i);
for(int k = 1; k <= 12; k++)
{
System.out.print(" " + k * i);
}
System.out.println();
}
}
}
If you want to get the formatting right you'll need to play around with determining the number of characters occupied by each int and thus how many spaces to print after each.
Bookmarks