Your Only Destination To Empower Your Computer Programing Knowledge. Sky is not so high, You can Touch it if You Try

java program's stock

Hello friends,
first of all I want to say sorry to you for long time i didn't post any article due to busy schedule of college life.Today i will discuss java programs.I am sure it will help you for some extent.


Program to find frequency of digits in a given number.

import java.util.*;
class Fod
{
public static void main(String ar[])
{
Scanner a1=new Scanner(System.in);
System.out.println("enter the number");
int n=a1.nextInt();
int m=0,sum=1,i,k=n,rem;
int a[]=new int[10];
while(n/10!=0)
{
sum++;
n=n/10;
}
System.out.println("no of digits is "+sum);
for(i=0;i {
rem=k%10;
a[rem]++;
k=k/10;

}
for(i=0;i<10;i++)
{
if(a[i]>0)
{
System.out.println("frequency of digit"+i+"="+a[i]);
}
}
}
}


Output:-


C:\Documents and Settings\Administrator>cd\

C:\>cd java

C:\java>cd bin

C:\java\bin>javac Fod.java

C:\java\bin>java Fod
enter the number
21341
no of digits is 5
frequency of digit1=2
frequency of digit2=1
frequency of digit3=1
frequency of digit4=1

C:\java\bin>


























No comments:

Post a Comment