Creating a program to identify even and odd numbers

Report a typo

You are given some scrambled code lines from a Java program that is designed to print whether numbers from 0 to 10 are odd or even. The program uses a ternary operator to check if the number is even or odd, and a for-loop for iterating over the numbers. Your task is to reorder the provided lines of code so that the program will work correctly. Note that you may not need to use all the given lines. Your solution should print 'Number x is even' or 'Number x is odd' where x is each number from 0 to 10."

Reorder lines using drag or arrows. Adjust indentation with left buttons
                public static void main(String[] args) {
              
                for (int i = 0; i <= 10; i++) {
              
                }
              
                String message = (i % 2 == 0) ? "even" : "odd";
              
                public class Main {
              
                }
              
                }
              
                System.out.println("Number " + i + " is " + message);
              

Create a free account to access the full topic