50) Write a program
to input a numbers and find the frequency
of any digit of this number, digit choose by the user. (124443=frequency of
4=3)
import java.util.*;
public class Frequency_of_a_digit
{
public static void main(String args[ ])
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter a number");
int a = sc.nextInt();
System.out.println("Enter a number of which you need FREQUENCY");
int b = sc.nextInt();
int p = a;
int c = 0;
while(p>0)
{
int d = p%10;
if(d==b)
{
c++;
}
p=p/10;
}
System.out.println("FREQUENCY of "+b+" in "+a+" = "+c);
}
}
Output :