Java Bar graph takes user input to create graph?
I am trying to copy the elements of an array input by the user starting at position 2 into another array called value and using that input starting a position 2 to create a graph.
Code java:
public static void main(String[] args) {
for (int i = 0; i < args.length; i++){
//Grabs the first 2 elements of the users input
int width = Integer.parseInt(args[0]);
int height = Integer.parseInt(args[1]);
//Controls the Height and Width of the frame
JFrame frame = new JFrame();
frame.setSize(height, width);
double[] value = new double[6];
String[] languages = new String[6];
//Controls the
value[0] = 50;
languages[0] = "Visual Basic";
value[1] = 2.5;
languages[1] = "PHP";
value[2] = 3;
languages[2] = "C++";
value[3] = 4;
languages[3] = "C";
value[4] = 5;
languages[4] = "Java";
value[5] = 6;
languages[5] = "Java";
frame.getContentPane().add(new SimpleBarChart(value, languages, "ProjectOne"));
WindowListener winListener = new WindowAdapter() {
public void windowClosing(WindowEvent event) {
System.exit(0);
}
};
frame.addWindowListener(winListener);
frame.setVisible(true);
}
}
}
Re: Java Bar graph takes user input to create graph?
When posting code, make sure you use code or highlight tags. I added them for you this time, but please be more mindful in the future.
What does your program do instead? Do you see an Exception? Some strange behavior? Something else?
Why do you have that in a for loop for each argument?