### Find the Frequency of Odd & Even Numbers in the given Matrix in Java

Note: 1An odd number is an integer which is not a multiple of two. If it is divided by two the result is a fraction.
2- The even numbers are all numbers that are multiples of 2.

public class CountEvenOdd {
public static void main(String args[]) {
int a[][] = new int;
int noOfOdd=0;
int noOfEven=0;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the element of Matrix ");

for (int i = 0; i <= 2; i++)
{

for (int j = 0; j <= 2; j++)

{
a[i][j] = sc.nextInt();

}

}
System.out.println("Value of  First Matrix is ");
for (int i = 0; i <= 2; i++)
{

for (int j = 0; j <= 2; j++)

{
System.out.print(a[i][j] + " ");

}

System.out.println();
}

for (int i = 0; i <= 2; i++)
{

for (int j = 0; j <= 2; j++)

{
if(a[i][j]%2==0)
{
noOfEven++;
}
else
{
noOfOdd++;
}

}

}

System.out.println("Tota even number "+noOfEven);
System.out.println("Tota odd number "+noOfOdd);
}

}

Output:

Enter the element of Matrix
1
2
3
4
5
6
7
8
9

Value of  First Matrix is
1 2 3
4 5 6
7 8 9

Tota even number 4
Tota odd number 5

BUILD SUCCESSFUL (total time: 7 seconds)