Skip to content

Commit 1e17b7d

Browse files
committed
Count number of even digits in a number
1 parent a0d3c70 commit 1e17b7d

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

evencheck.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
1+
/* Count number of even digit in a number
2+
* If the count greater than or equal to 3, then print "True" otherwise "False"
3+
*/
24
import java.util.*;
3-
45
public class evencheck
56
{
67
public static void main(String[] args)
78
{
89
int n;
910
Scanner sc = new Scanner(System.in);
10-
n = sc.nextInt();
1111
int count = 0;
12+
/*
13+
n = sc.nextInt();
1214
while(n>0)
1315
{
1416
int rem = n%10;
@@ -17,6 +19,15 @@ public static void main(String[] args)
1719
}
1820
n = n/10;
1921
}
22+
*/
23+
String num = sc.nextLine();
24+
for (int i = 0; i < num.length(); i++)
25+
{
26+
if(Integer.parseInt(String.valueOf(num.charAt(i)))%2==0)
27+
{
28+
count++;
29+
}
30+
}
2031
if(count>=3)
2132
{
2233
System.out.print("True");

0 commit comments

Comments
 (0)