66.7k views
2 votes
Write a java program that asks the user for a certain number between 1 and 100, then the program prints all the multiples of this number below 10000.

User Leonheess
by
7.4k points

1 Answer

3 votes

Answer:

Here is the Java code:

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner scanner = new Scanner(System.in);

System.out.print("Enter a number between 1 and 100: ");

int num = scanner.nextInt();

for (int i = num; i < 10000; i += num) {

System.out.println(i);

}

}

}

Step-by-step explanation:

Note: The above program will print all the multiples of the given number below 10000, it will not print 10000. If you also want to print 10000, you can change the condition in the for loop to i <= 10000.

User Ajiri
by
7.3k points