Home > Java > Javagetting Started > How to implement the ninety-nine multiplication table in java

How to implement the ninety-nine multiplication table in java

王林
Release: 2020-10-20 14:47:57
Original
37181 people have browsed it

How to implement the ninety-nine multiplication table in Java: Construct a two-layer nested for loop. The outer for loop is used to control the row, and the inner for loop is used to control the multiplication expression on a certain row. Each row Just wrap the output after finishing the output.

How to implement the ninety-nine multiplication table in java

Idea:

Construct a two-layer nested for loop: the outer loop is used to control rows, and the inner loop is used to control a certain Multiplication expressions on lines.

It should be noted that after each line is output, a line break is required.

(Recommended tutorial: java video tutorial)

Code implementation:

public class Test1 {
	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+"="+(i*j)+"  ");
			}
			System.out.println();
		}
	}
}
Copy after login

Result:

How to implement the ninety-nine multiplication table in java

Code implementation:

public class Test {
	public static void main(String[] args){
		for(int i=1;i<=9;i++){
			for(int j=1;j<=9;j++){
				System.out.print(j+"*"+i+"="+(i*j)+"\t");
			}
			System.out.println();
		}
	}
}
Copy after login

Result:

How to implement the ninety-nine multiplication table in java

##Related recommendations:

java tutorial

The above is the detailed content of How to implement the ninety-nine multiplication table in java. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template