-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeetCode.java
More file actions
31 lines (31 loc) · 848 Bytes
/
Copy pathLeetCode.java
File metadata and controls
31 lines (31 loc) · 848 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
public class LeetCode{
public static int Digit(int num){
int count=0;
while(num>0){
count++;
num/=10;
}
return count;
}
public static boolean Even(int num){
int NumberOfDigits = Digit(num);
return NumberOfDigits % 2 == 0;
}
public static int TotalEvenNumbers(int[] arr){
int count = 0;
int num;
for(int index=0; index<arr.length; index++){
num = arr[index];
if(Even(num)){
count++;
}
// return count;
}
return count;
}
public static void main(String[] args){
int[] arr = {124, 34, 5562, 324, 34};
int EvenNumbersInArr = TotalEvenNumbers(arr);
System.out.println(EvenNumbersInArr);
}
}