Q:

A graphic representation of occurence of numbers and letters with asteriks

DISCLAIMER: THIS IS PART OF A HOMEWORK ASSIGNMENT
So i have created an array with the the count of each letter. It would look something like this: 
Array charCount
charCount[0] = 10
charCount[1] = 6
charCount[2] = 4

I know that 0 = a, 1 = b etc. 
Now I want to print these results to a graphic representation using asteriks. For example: 
*
*
*
*
*
**
**
**
***
***
***
ABC

I found this rather difficult and don't really understand how to do this.
- I've made a function to check the max value of my array. 
for (int i = 0; i < charCount.length; i++) {
    if (letterCount[i] > maxInt) {
    maxInt = charCount[i]; 
    }
}

Then I've made a for loop to check if there are any matches. 
My next part of code is:
for (int i = 0; i < letterCount.length; i++ ) {
    for (int j = 0; j <= maxInt; j++) {
        if (letterCount[i] == maxInt) {
        System.out.println("*");
        } if (letterCount[i]  == maxInt - j ) {
        System.out.println("*");
        } if (letterCount[i] != maxInt ) {
        System.out.println(" ");
    }
}

But here it where I got stuck. 

How do i print asteriks all the way down and next to each other? Should I work with spaces?
How do i know when to stop printing? Does my maxInt - j makes sense? 

Can someone point my in the right direction? 
I have to come up with a solution using for loops and arrays, So i cant use any fancy methods yet :) 
Thank you :) 

A:

Imagine you wanna draw this like a bar graph to a grid, which has coordinates, similar to what you did in school with x and y coordinates.
To stay with your example, each y coordinate represents the index of your array, e.g. the specific letter, where the x - coordinate the amount.
Since those numbers may get quite large, it's, like you saw, not best practice to map +1 on the x-coordinate to +1 letter.
Therefore you need to determine the size of your diagram, let's say it shall be 10 letters wide:
 y  <- 10
 ^
a|**********
b|**********
c|**********
-------------> x 
  12345 ...10

Now it's important that the occurences of the letters relative to each other are represented correctly by those *-bars, that means the letter which occurs the most could be shown with a bar exactly as long as you draw the x-coordinate, in this case 10.
Lets use this as an example dataset
0 := 10
1 := 6
2 := 4
3 := 14

If the x-coordinate is 10 * long, the amount from entry 3 (highest in the array) is 14 and needs to be 10 * long. With this information you can calculate the factor by dividing 10(x-length) / 14(biggest amount) ~= 0.71 (the factor)
This factor you apply to all the numbers to get number of stars to draw.
Here as an example in java:
int xLength = 10;
int[] charCount = new int[5];
charCount[0] = 10;
charCount[1] = 4;
charCount[2] = 7;
charCount[3] = 14;
charCount[4] = 1;

// determine the biggest value:
int biggest = 0;
for(int n:charCount) {
    if(n>biggest)
        biggest = n;
}
System.out.println("Biggest no: " + biggest);

double factor = (double)xLength / (double)biggest;
System.out.println("Using factor: " + factor);

for(int i = 0; i < charCount.length; i++) {
    System.out.print("no " + i + ":");
    for(int j = 0; j < charCount[i] * factor; j++) {
        System.out.print("*");
    }
    System.out.println();
}

This will output:
Biggest no: 14
Using factor: 0.7142857142857143
no 0:********
no 1:***
no 2:*****
no 3:**********
no 4:*

EDIT:
If you want to print the bars vertically (on the y-choordinate), or turn it any other way, store the bars in a grid, for example with a String[][] array, where arr[2][3] would be y-coordinate 2 and x-coordinate 3. Then you can calculate with the factor above and the maximum height of the chart whether or not a specific point / coordinate should be filled with a "*" or a " " (nothing):
    // make a grid to draw the chart
    // the height is the the number we defined as maximum height (xLength)
    // and the width is one column for every char (charCount.length):
    String[][] grid = new String[charCount.length][xLength];

    // initialize the grid with spaces:
    for(int x = 0; x < grid.length; x++) {
        for(int y = 0; y < grid[x].length; y++) {
            grid[x][y] = " ";
        }
    }

    // We will go through the grid column by column:
    for(int x = 0; x < grid.length; x++) {
        // this will be called once for every char
        // so just replace spaces in the grid in this column
        // by "*" if it's a row (value of y) <= the amount
        // of chars times the factor
        for(int y = 0; y < grid[x].length; y++) {
            if(y <= charCount[x] * factor) {
                grid[x][y] = "*";
            }
        }
    }

    // print the grid row by row (think of it upside down, (0,0) is the upper left point
    // so we start with the last (the no of elements in the array minus 1, counting from 0)
    System.out.println("^");
    for(int y = grid[0].length - 1; y >= 0; y--) {
        System.out.print("|");
        for(int x = 0; x < grid.length; x++) {
            System.out.print(grid[x][y]);
        }
        // finish the line:
        System.out.println();
    }
    // draw the bottom line:
    System.out.println("------->");
    System.out.println(" abcde");

Added this code just below the code from above, the output will be:
Biggest no: 14
Using factor: 0.7142857142857143
no 0:********
no 1:***
no 2:*****
no 3:**********
no 4:*
^
|   * 
|   * 
|*  * 
|*  * 
|* ** 
|* ** 
|* ** 
|**** 
|**** 
|*****
------->
 abcde

If you want to put the amounts left to the y-bar, divide the row number by the factor.
If you want to use the absolute values without scaling up or down (which would fill the screen pretty fast for big numbers), just set the 'xLength' (height of the grid) to the biggest number in the input array.

