-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain181.java
More file actions
31 lines (22 loc) · 801 Bytes
/
Main181.java
File metadata and controls
31 lines (22 loc) · 801 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
package loopinjava;
import java.util.Scanner;
public class Main181 {
public static void main(String[] args) {
int i, count, digit, freqCount[] = new int[10], number;
Scanner input = new Scanner(System.in);
System.out.println("Find frequency of each digit in a given integer.\n");
System.out.print("Enter a number: ");
number = input.nextInt();
while (number != 0) {
digit = (number % 10);
number = (number / 10);
freqCount[digit]++;
}
for (i = 0; i <= 9; i++) {
/// if(freqCount[i] > 0) /** This line will be print, if frequency is greater than 0.*/
{
System.out.println("Frequency of " + i + " = " + freqCount[i]);
}
}
}
}