-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnew_ja.java
More file actions
36 lines (29 loc) · 932 Bytes
/
new_ja.java
File metadata and controls
36 lines (29 loc) · 932 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
import java.util.Scanner;
class PrimeNumbers{
public static void main (String[] args){
Scanner in = new Scanner (System.in);
System.out.print("enter the number of elements : ");
int n = in.nextInt();
int x;
System.out.println("Enter the elements : ");
int eve=0,eve_cou=0,od=0,od_cou=0;
for(int i=1; i<=n; i++)
{
x = in.nextInt();
if(x%2==0){
eve += x;
eve_cou += 1;
}
else{
od += x;
od_cou += 1;
}
}
System.out.print("count of even numbers : "+eve_cou+"\n");
System.out.print("sum of even numbers : "+eve+"\n");
System.out.print("average of even numbers : "+eve/eve_cou+"\n\n");
System.out.print("count of odd numbers : "+od_cou+"\n");
System.out.print("sum of odd numbers : "+od+"\n");
System.out.print("average of odd numbers : "+od/od_cou+"\n");
}
}