-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
49 lines (47 loc) · 781 Bytes
/
Copy pathMain.java
File metadata and controls
49 lines (47 loc) · 781 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import java.util.*;
import java.lang.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System . in);
int a=sc.nextInt();
if(a<=0)
{
System.out.println("Number cannot be zero or negative");
}
if(a>32767)
{
System.out.println("number exceeded the limit");
}
int b=a;
int rem,count=0,even=0;
int [] val=new int[20];
for(int i=0;b>0;i++)
{
val[i]=b%10;
b=b/10;
count++;
if(val[i]%2==0)
{
even++;
}
}
int sum=0,sqr;
if(a!=0 && even == 0)
{
System.out.println("Even digit not found");
}
else if(even > 0 )
{
for(int i=0;i<count;i++)
{
if(val[i]%2==0)
{
sqr=val[i]*val[i];
sum=sum+sqr;
}
}
System.out.println(sum);
}
}
}