Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Formatter;
- public class MultiplicationTable {
- public static void main(String[] args) {
- StringBuilder sb = new StringBuilder();
- Formatter f = new Formatter(sb);
- f.format(" |");
- for (int i = 1; i < 10; i++) f.format("%3d", i);
- f.format("\n");
- for (int i = 0; i < 3 * 9 + 2; i++) f.format("-");
- f.format("\n");
- for (int i = 1; i < 10; i++) {
- f.format("%d|", i);
- for (int j = 1; j < 10; j++) {
- f.format("%3d", i * j);
- }
- f.format("\n");
- }
- System.out.println(f);
- f.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement