-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChe10Exce20_Array.java
More file actions
26 lines (20 loc) · 909 Bytes
/
Copy pathChe10Exce20_Array.java
File metadata and controls
26 lines (20 loc) · 909 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
import java.util.*;
public class Che10Exce20_Array {
public static void main(String[] args) {
int[] array_nums = {10, 11, 10, 30, 45, 20, 33, 53};
int result = 0;
System.out.println("Original Array: "+Arrays.toString(array_nums));
int ctr1 = 0;
// Initialize a counter to count occurrences of value 10
int ctr2 = 0
// Initialize a counter to count occurrences of value 20
for(int i = 0; i < array_nums.length; i++) {
if(array_nums[i] == 10)
ctr1++; // Increment ctr1 when the element is equal to 10
if(array_nums[i] == 20)
ctr2++; // Increment ctr2 when the element is equal to 20
}
System.out.printf(String.valueOf(ctr1 > ctr2)); // Check if the count of 10 is greater than the count of 20
System.out.printf("\n");
}
}