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

Program to print histogram of numbers


import java.util.*;
class Histogram
{
public static void main(String arg[])
{
System.out.println("Enter any number");
Scanner a1= new Scanner(System.in);
int n= a1.nextInt();
int i=0,j,k,r;
int ar[]=new int[50];
while(n>0)
{
r=n%10;
ar[i]=r;
i++;
n=n/10;
}
for(j=ar[i];j<=0;j--)
{
k=ar[i];
for(int l=0;l {
System.out.print("*");
}
System.out.println("");
i--;
}
}
}






Output:-


C:\Documents and Settings\Administrator>cd\

C:\>cd\java\bin

C:\java\bin>javac Histogram.java

C:\java\bin>java Histogram
Enter any number
342

***
****
**


















1 comment:

  1. I am here to discuss about Histogram as-A graphical representation which shows a visual impression of the distribution of data termed as Histogram . Histogram consists of tabular frequencies which are shown as adjacent rectangles, with an area equal to the frequency of the observations in the interval.
    How to do Ratios

    ReplyDelete