-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram220.java
More file actions
87 lines (66 loc) · 1.7 KB
/
Copy pathprogram220.java
File metadata and controls
87 lines (66 loc) · 1.7 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.util.Scanner;
class NNumberX
{
public int Arr[];
public NNumberX(int iSize)
{
Arr = new int[iSize]; // Resource Allocation
System.out.println("Allocating the resources...");
}
protected void finalize()
{
Arr = null;
System.out.println("Deallocating the resources...");
}
public void Accept()
{
int iCnt = 0;
Scanner sobj = new Scanner(System.in);
System.out.println("Enter the element :");
for(iCnt = 0 ; iCnt < this.Arr.length ; iCnt++)
{
this.Arr[iCnt] = sobj.nextInt();
}
sobj = null;
}
public void Display()
{
int iCnt = 0;
System.out.println("Entered elements :");
for(iCnt = 0 ; iCnt < this.Arr.length ; iCnt++)
{
System.out.println(this.Arr[iCnt]);
}
}
public int CountEven()
{
int iCount = 0;
int iCnt = 0;
for(iCnt = 0 ; iCnt < Arr.length ; iCnt++)
{
if((Arr[iCnt] % 2) == 0)
{
iCount++;
}
}
return iCount;
}
}
class program220
{
public static void main(String A[] )
{
int iCnt = 0;
int iCount = 0;
int iRet = 0;
Scanner sobj = new Scanner(System.in);
System.out.println("Enter number of elements :");
int iSize = sobj.nextInt();
NNumberX nobj = new NNumberX(iSize);
nobj.Accept();
nobj.Display();
iRet = nobj.CountEven();
System.out.println("Number of Even elements are : "+iRet);
sobj = null;
}
}