Read the question, write Java on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read n. Print n x 1 = … through n x 10 = …
Examples
Input
3
Output
3 x 1 = 3 3 x 2 = 6 3 x 3 = 9 3 x 4 = 12 3 x 5 = 15 3 x 6 = 18 3 x 7 = 21 3 x 8 = 24 3 x 9 = 27 3 x 10 = 30
Hint
- for (int i = 1; i <= 10; i++)
Show correct code
Peek only after you have tried. You can still Check your own version.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
for (int i = 1; i <= 10; i++) {
System.out.println(n + " x " + i + " = " + n * i);
}
}
}
Main.javaJava 21 · javac · Ctrl + Enter runs
ResultIdle
Run to see output. Check grades the tests.