title: How to make a grade bar chart in java
body: <p>This is my homework problem, but i cant seem to get it straight. This program prompts the user to enter the number of students and then prompts the user to enter a grade percentage (0-100) for each student. Only thing i can't get right is that I cant draw the columns in the correct positions. The columns will be 0.5 space apart. Note the number of student will be the horizontal axes and grade will be the vertical axes. The comments I included on the code are what i need help in. Thanks</p>
  
  <pre><code>import java.util.*;
  import javax.swing.JOptionPane;
  
  
  public class GradesChart{
    public static void main (String [] args) {
  
    drawAxes(); //Call method to draw the axes intersecting at (0.1,0.1)
  
    String input = JOptionPane.showInputDialog(null,"Please enter the number of students.");
    int input2 = Integer.parseInt(input);
  
    double columnnWidth = 0.5; // *** HOW TO CALCULATE THE COLUMN WIDTH???****
  
    for (int grade = 0; grade &lt; input2; grade++){
        JOptionPane.showInputDialog(null, "Please enter the grade of student. ");
      drawColumn(columnnWidth, input2 , grade);
      /**IN THIS FOR LOOP I WANT TO PROMPT USER TO ENTER THE GRADE OF EACH STUDENT (0-100)
      AND DRAW A COLUMN THAT REPRESENTS THE GRADE **/
    }
    }
  
    public static void drawAxes() {
      StdDraw.setPenColor(StdDraw.BLACK);
      StdDraw.line(0.0,1.0,0.0,0.0);
      StdDraw.line(0.0,0.0,1.0,0.0);
    }
  
    public static void drawColumn(double width, int studentIndex, int grade) {
      StdDraw.setPenColor(StdDraw.BLUE);
      StdDraw.filledRectangle(studentIndex, grade, width, 1.0);
    }
  
  }
  </code></pre>