Assignment #114: Multiplication Table
Code
public class TimesTable {
public static void main(String[] args) {
System.out.println("x | 1 2 3 4 5 6 7 8 9");
System.out.println("===+===================================");
for ( int n = 1; n <= 12; n++) {
if (n < 10) {
System.out.print(n + " | ");
}
else if (n >= 10) {
System.out.print(n + " | ");
}
for (int x = 1; x <= 9; x++) {
if ((x * n) < 10) {
System.out.print((x * n) + " ");
}
else if ((x * n) >= 10) {
System.out.print((x * n) + " ");
}
}
System.out.print("\n");
}
}
}
Picture of the output