الرجوع
تسجيل الدخول
أنت تتصفح نسخة مؤرشفة من الموقع اضغط للانتقال إلى الموقع الجديد بكامل المزايا
import java.util ____ .Scanner;

public class PrintIntegers {
    public ____ void main(String[] args) {
        // Create a Scanner object to read input from the console
        ____ scanner = new Scanner(System.in);
        ____ userInput; // Declare a variable to store the user's input

        do {
            // Prompt the user to enter a non-negative integer
            System.out.print("Enter a non-negative integer number: ");
            userInput = ____ .nextInt();

            if (userInput ____ 0) {
                System.out.println("Invalid input. Please enter a non-negative integer.");
            }
        } ____ (userInput ____ 0); // Repeat until a non-negative integer is entered

        // Inform the user about the start of the loop
        System.out.println("Printing numbers from " + ____ + " to 0:");

        // print numbers from user's input to 0 (inclusive)
        for (int i = userInput; i >= 0; ____) {
            ____ (i);
        }
    }
}