67) Write a program to find Frequency of Every Digit in a number?(1616336331, 1 - 3 times, 3 - 4 times, 6 – 3 times)
import java.util.*;public class Frequency_of_digits{public static void main(String args[ ]){Scanner sc = new Scanner (System.in);System.out.println("Enter a number");int b = sc.nextInt();int a = b;while(a>0){int d = a%10;int z = b;int f = 0;int t = 0;while(z>0){if(d==z%10&&z>a){t++;}else if(d==z%10&&t==0){f++;}z=z/10;}a=a/10;if(f>0){System.out.println("FREQUENCY OF "+d+" = "+f+" Times");}}}}
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal