# Occurrences of the Given Digit in Java …fcukthecode

Calculate the number of occurrences of the given input digit in the given numbers.

Input
The first line of input consists of a single integer T, denoting the number of integers.
The Second line integer input of the digit.
The Third line integer input of the numbers in which you have to search the occurrences of the digit in the given number.

Output:
Output T lines. Each of these lines should contain the number of occurrences of the digit.

``````Input:
Enter the TestCases:  2
Enter the Digit:  2
Enter any number:  1011011101012
Output:
Count = 1

Enter the Digit:  6
Enter any number:  481216202466
Output:
Count = 3``````
```import java.io.*;
import java.util.*;
public class temp{
public static void main(String[] args) throws IOException
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter the TestCases:  ");
int t=sc.nextInt();
for(int i=0;i<t;i++)
{
System.out.print("Enter the Digit:  ");
int D=sc.nextInt();

System.out.print("Enter any number:  ");
long n=sc.nextLong();

long count=0,rem=0;

while(n!=0)
{
rem=n%10;
n=n/10;

if(rem==D)
{
count++;
}
}
System.out.println("Count = "+count);
}
}
}
```

INPUT_1:
Enter the TestCases: 2
Enter the Digit: 1
Enter any number: 1011254548
OUTPUT:
Count = 3
Enter the Digit:  5
Enter any number:  6515151
Count = 3

INPUT_2:
Enter the TestCases:  1
Enter the Digit:  9
Enter any number:  944514215479

OUTPUT:
Count = 2

INPUT_3:
Enter the TestCases:  3
Enter the Digit:  1
Enter any number:  101
OUTPUT:
Count = 2

Enter the Digit:  5
Enter any number:  102154
OUTPUT:
Count = 1

Enter the Digit:  3
Enter any number:  5645
OUTPUT:
Count = 0

ILLUSTRATION