Using WHILE LOOP statement
Write a Program that will ask the user to accept an
integer input and outputs message below:
Print Numbers Descending (from 1000)
Enter the number that you want to print:
Number of iterations:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
System.out.println("Print Numbers Descending (from 1000)");
System.out.println("Enter the number that you want to print:");
int number = in.nextInt();
System.out.println("Number of iterations:");
int iterations = in.nextInt();
while (iterations > 0) {
System.out.println(number);
iterations--;
}
}
}
Comments
Leave a comment