You have been given an array of integer values. Your task is to fill the blanks in code to iterate over this array, determine whether each number is odd or even, and print a message that states 'The number [number] is [odd/even].' Note that the array length might change so your solution should be dynamic. You need to use a loop, a condition and certain predefined array properties.
Iterating over arrays
Determining even or odd numbers in an array
Report a typo
Fill in the gaps with the relevant elements
public class Main{
public static void main(String[] args){
int[] numbers = {5, 10, 15, 20, 25};
(int i = 0; i < numbers.; i++){
(numbers[i] % 2 == 0){
System.out.println("The number " + numbers[i] + " is even.");
} else{
System.out.println("The number " + numbers[i] + " is odd.");
}
}
}
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.