如何在 java 中制作成绩条形图

How to make a grade bar chart in java

这是我的作业题,但我似乎无法弄清楚。该程序提示用户输入学生人数,然后提示用户输入每个学生的成绩百分比 (0-100)。我唯一不能做对的是我无法在正确的位置绘制列。列将相隔 0.5 space。请注意,学生人数将是水平轴,年级将是垂直轴。我在代码中包含的注释是我需要帮助的地方。谢谢

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 < 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);
  }

}

使用 JFreeCharts 库。请参阅此示例以获取更多信息:http://www.tutorialspoint.com/jfreechart/jfreechart_bar_chart.htm