-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOddEvenArray.java
More file actions
31 lines (28 loc) · 829 Bytes
/
Copy pathOddEvenArray.java
File metadata and controls
31 lines (28 loc) · 829 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
28
29
30
31
import java.util.Scanner;
class OddEvenArray {
public static void printArray(int[] array) {
for (int item : array) {
System.out.print(item);
System.out.print(' ');
}
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int[] numbers = new int[10];
for(int i=0; i<= 9; i++) {
numbers[i] = scan.nextInt();
}
int odd = 0, even = 0;
for(int i=0; i<= numbers.length-1; i++) {
if(numbers[i] % 2 == 0) {
even += 1;
}
else {
odd += 1;
}
}
printArray(numbers);
System.out.println(String.format("You have entered %s odd numbers and %s even numbers", odd,even));
scan.close();
}
}