code show as below:
public class PrintMultiplication{
public static void main(String[] args){
for(int i = 1; i<=9; i++){
for(int j = 1; j<=i; j++){
System.out.print(j+"*"+i+"="+j*i+" ");
}
System.out.println();
}
}
}
Misalignment will appear after printing:
Change the space in System.out.print(j+" "+i+"="+j i+" "); to \t, \ is the escape character, and t represents the tab key:
Code improvements:
import java.util.Scanner;
public class PrintMultiplication{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
print99(n);
}
public static void print99(int n){
for(int i = 1; i<=n; i++){
for(int j = 1; j<=i; j++){
System.out.print(j+"*"+i+"="+j*i+"\t");
}
System.out.println();
}
}
}
Implement method call, implement manual input of cut-off number: