How could I insert hyphens (-) to separate the rows and pipe symbols (|) to separate the columns in this code? I have tried a little bit but im only able to insert for the first row only.
public class Latin
{
public static void main (
String[] args) {
final int N = 10;
for (int i = 1; i <= N; i++)
System.out.print(pad(i) + "|");
System.out.println();
System.out.print("---+");
for (int i = 1; i <= N; i++)
System.out.print("----");
System.out.println();
for (int i = 1; i <= N; i++) {
System.out.print(pad(i) + "|");
for (int j = 1; j <= N; j++) {
System.out.print(pad(i*j) + " ");
}
System.out.println();
}
}
public static String pad(int x) {
String s = new String();
if (x < 10) s = " " + x;
else if (x < 100) s = " " + x;
else s = "" + x;
return s;
}
}