-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEvenOdd.java
More file actions
27 lines (22 loc) · 774 Bytes
/
Copy pathEvenOdd.java
File metadata and controls
27 lines (22 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package basics.for_statement;
import java.util.Scanner;
public class EvenOdd {
public static void main(String[] args) {
// Get user input
Scanner scanner = new Scanner(System.in);
System.out.print("Enter lower bound value: ");
int lower_bound = scanner.nextInt();
System.out.print("Enter upper bound value: ");
int upper_bound = scanner.nextInt();
computeEven(lower_bound, upper_bound);
}
private static void computeEven(int lower_bound, int upper_bound) {
for (int i = lower_bound; i < upper_bound; i++) {
if (i % 2 == 0) {
System.out.println(i + " is even");
} else {
System.out.println(i + " is odd");
}
}
}
}