-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram537.java
More file actions
86 lines (66 loc) · 1.71 KB
/
Copy pathprogram537.java
File metadata and controls
86 lines (66 loc) · 1.71 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
import java.util.*;
class Matrix
{
private int Arr[][];
public Matrix(int A , int B)
{
Arr = new int[A][B];
}
public void Accept()
{
System.out.println("Please enter the elemets of matraix: ");
Scanner sobj = new Scanner(System.in);
int i =0 , j =0;
for(i = 0; i <Arr.length;i++)
{
for( j= 0 ; j < Arr[i].length;j++)
{
Arr[i][j] = sobj.nextInt();
}
}
}
public int CountEven()
{
System.out.println("Please enter the elemets of matraix: ");
Scanner sobj = new Scanner(System.in);
int i =0 , j =0 ,iCount =0;
for(i = 0; i <Arr.length;i++)
{
for( j= 0 ; j < Arr[i].length;j++)
{
if(Arr[i][j] %2 == 0)
{
iCount++;
}
}
}
return iCount;
}
public void Display()
{
System.out.println("Elemets of matraix are : ");
int i =0 , j =0;
for(i = 0; i <Arr.length;i++)
{
for( j= 0 ; j < Arr[i].length;j++)
{
System.out.print(Arr[i][j]+"\t");
}
}
}
}
public class program537
{
public static void main(String[] args)
{
Scanner sobj = new Scanner(System.in);
System.out.println("Enter number of rows: ");
int iRow = sobj.nextInt();
System.out.println("Enter number of colums: ");
int iCol = sobj.nextInt();
Matrix mobj = new Matrix(iRow,iCol);
mobj.Accept();
mobj.Display();
int iRet = mobj.CountEven();
}
}