Results 1 to 4 of 4
  1. #1
    deepaktomar is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Cool histogram program in java

    histogram pattern program in java


    public class histogram{

    public static void main(String args[]){

    int n = args.length;
    int max = 0,j,i;
    int a[]= new int[20];
    for(i=0;i<n;i++)
    {
    a[i]=Integer.parseInt(args[i]);

    }

    for(i=0;i<n;i++)
    {
    if(a[i]>max)
    {
    max = a[i];
    }
    }

    for(i=max;i>0;i--)
    {
    for(j=0;j<n;j++)
    {
    if(a[j]==i)
    {
    System.out.print("*");
    a[j]-=1;
    }
    else
    {
    System.out.print(" ");
    }
    }
    System.out.print("\n");
    }

    }//end of main method
    }//end of class

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Do you have a question about this?

  3. #3
    deepaktomar is offline Member
    Join Date
    Mar 2011
    Posts
    2
    Rep Power
    0

    Default

    no its just a program that i made by myself
    and wanted to put it on my blog so that it could help anyone who needed this program

  4. #4
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

Similar Threads

  1. JAI Histogram error
    By deepsri in forum Advanced Java
    Replies: 0
    Last Post: 01-07-2011, 10:06 AM
  2. histogram
    By little_man in forum New To Java
    Replies: 4
    Last Post: 11-13-2010, 01:38 AM
  3. Replies: 8
    Last Post: 11-24-2009, 09:03 PM
  4. Regarding the display of histogram
    By Mazharul in forum Java 2D
    Replies: 2
    Last Post: 08-27-2008, 03:09 AM
  5. How to create a Histogram
    By Devilsfutbol17 in forum New To Java
    Replies: 4
    Last Post: 06-04-2008, 09:22 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •