The method outputs the corresponding multiplication table according to the data input by keyboard.

Time:2019-7-28

According to the keyboard input data output corresponding multiplication table:

import java.util.Scanner;
class Hello2 {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);
         System.out.println ("Please enter an integer of 1-9");
         int x = sc.nextInt();
         print(x);
    }

    public static void print(int a) {
        for(int i = 1;i <=a;i++) {
           for(int j = 1;j <=i;j++) {
              System.out.print(j + "*" + i + "=" + (i * j) + '\t');
           }
           System.out.println();
        }
    }
}

Result:

 

Recommended Today

Large scale distributed storage system: Principle Analysis and architecture practice.pdf

Focus on “Java back end technology stack” Reply to “interview” for full interview information Distributed storage system, which stores data in multiple independent devices. Traditional network storage system uses centralized storage server to store all data. Storage server becomes the bottleneck of system performance and the focus of reliability and security, which can not meet […]