打印99乘法表

import java.util.*;
class Main {
  public static void main(String[] args){
    //Display the table heading
    System.out.println("          Multiplication Table");
    //Display the number title
    System.out.print("   ");
    for(int j = 1; j <= 9 ; j++){
      System.out.print("   " + j);
    }
    System.out.println("\n----------------------------------------");
    //Print table body
    for(int i = 1; i <= 9;i++){
      System.out.print(i + " |");
      for(int j = 1; j <= 9; j++){
        //Display the product and align properly
        System.out.printf("%4d", i*j);
      }
      System.out.println();
    }
  }
}
posted @ 2022-05-19 19:58  Scenery_Shelley  阅读(20)  评论(0)    收藏  举报