006-005-003
Continue Statement: Display Even Numbers Only
Easy
Problem Description
Continue Statement: Display Even Numbers Only
Learning Objective: Skip part of loop with continue statement
In this problem, you will create a program that uses the continue statement to skip odd numbers and extract only even numbers from an input sequence, displaying them to standard output.
Create program that inputs number sequence and displays only even numbers. Use continue statement to skip displaying odd numbers.
Input
Line 1: Number count (integer)
Line 2 onwards: Numbers (integer, multiple lines)
Output
[even1]
[even2]
...
```java
(display only even numbers).
Test Cases
※ Output examples follow programming industry standards
Normal case
Input:
5 1 2 3 4 5
Expected Output:
2 4
Normal case
Input:
3 10 20 30
Expected Output:
10 20 30
Boundary case
Input:
4 1 2 3 5
Expected Output:
2
problem.testType.edge
Input:
1 2
Expected Output:
2
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 10 free executions remaining
