Advertisement
cd62131

MultiplicationTableWithoutFormatter

Jul 11th, 2014
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.59 KB | None | 0 0
  1. public class MultiplicationTableWithoutFormatter {
  2.   public static void main(String[] args) {
  3.     StringBuilder sb = new StringBuilder();
  4.     sb.append(" |");
  5.     for (int i = 1; i < 10; i++) sb.append("  " + i);
  6.     sb.append("\n");
  7.     for (int i = 0; i < 3 * 9 + 2; i++) sb.append("-");
  8.     sb.append("\n");
  9.     for (int i = 1; i < 10; i++) {
  10.       sb.append("" + i + "|");
  11.       for (int j = 1; j < 10; j++) {
  12.         int mul = i * j;
  13.         if (mul < 10) sb.append("  " + mul);
  14.         else sb.append(" " + mul);
  15.       }
  16.       sb.append("\n");
  17.     }
  18.     System.out.print(sb);
  19.   }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement