-
Notifications
You must be signed in to change notification settings - Fork 0
/
YT08.java
40 lines (34 loc) · 952 Bytes
/
YT08.java
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
import java.io.*;
class YT08
{
public static void main(String[] args)throws IOException
{
int a[]= new int[20];
int sum=0;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
//user accept= values
System.out.println("Enter the array: ");
for(int i=0; i<20; i++)
{
a[i]=Integer.parseInt(br.readLine());
}
//original array print
System.out.println("Original Array: ");
for(int i=0; i<20; i++)
{
System.out.print(a[i]+ " ");
}
//suming process
for(int i=0; i<20; i++)
{
if(a[i]%3==0 || a[i]%5==0)
{
sum=sum+a[i];
}
}
//Result print
System.out.println();
System.out.println("SUM: "+ sum);
}
}