-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNumbers.java
More file actions
44 lines (42 loc) · 912 Bytes
/
Numbers.java
File metadata and controls
44 lines (42 loc) · 912 Bytes
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
import java.util.*;
public class Numbers
{
long num;
Numbers()
{
num=0;
}
void Input()
{
Scanner as =new Scanner (System.in);
System.out.println("\tThe Frequency of Digits Program\n");
System.out.println("Enter the Number:" );
num=as.nextLong();
}
void digitFrequency()
{
long num1=num,k=0;
int i,j,c=0;
System.out.println("\t\tThe Number Given:"+num);
System.out.println("\t\t Your Desired Output\n");
for(i=0;i<=9;i++)
{
num1=num;
while(num1!=0)
{
k=num1%10;
if(k==i)
c++;
num1/=10;
}
System.out.println("The Frequency of "+i+" is "+c);
c=0;
}
}
public static void main(String args[])
{
Numbers n=new Numbers();
n.Input();
n.digitFrequency();
}
}