Object-Oriented Programming with Java, part I – Exercise 28

This program displays from 100 down to 1 using a while loop and then stops.

My Code

public class FromHundredToOne {

    public static void main(String[] args) {
        // Write your program here
        int number = 101;
        
        while (number > 1){
            number --;
            System.out.println(number);
        }
    }
}

Model Code

public class FromHundredToOne {

 

    public static void main(String[] args) {

        // Write your program here

        int number = 100;

 

        while (number >= 1) {

            System.out.println(number);

            number--;

        }

    }

}

Leave a comment