create a program that plots the test scores on a particular test, for all 40 stu
ID: 3674130 • Letter: C
Question
create a program that plots the test scores on a particular test, for all 40 students in the class. The plot will use two JavaFX Node types to plot the scores, a) a circle, or rather an ArrayList of them, and b) a Polyline. A file with 40 test scores is made available to you, along with these instructions, that you are to use to create the plot. The plot shows the overall shape of the score distribution. In our screen capture notice that the scores are plotted close to a smiley face, since quadrants III and IV are for scores in the range 50-100. Thus, the overall shape, tells us something about the success or failure characteristics of a particular test.
(1) First task is to read the test scores into an ArrayList object. Notice that we are using generics here, so for now, go along with the syntax. Refer to ch14 as mentioned. Once read in, sort the array, using the ArrayList's sort() method. No extra efort this time from you. Thank you Java. (2) The next steps deal with the creation of the plot. Notice that you will need a Pane to draw within it, along with Lines, Text, Circles and a Polyline. You need to draw the scores as small circles, of any color you like, along with the polyline connecting all the scores. Again, the color can be to your choosing. The scale of the plot is based on my scene of 600x600 and a pane of the same dimensions. (3) The axes should be centered in the pane, and drawn inset 50px on either side, in both dimensions. If you choose a diferent scene or pane size, adjust accordingly. The labels represent the test score range 0-100. (4) The points now. Each point represents a test score, so using each point's polar coordinates you will compute each point's x and y coordinates. The radius is simply the exam score, multiplied by 2 (for my 600x600 pane) to scale it a bit so the plot looks nicer. The angle is also based on the score, and ranges between 0-360, corresponding to test scores 0-100. So, a test score of 50 would be plotted at 180 degrees, and a score of 12 would be at 45 degrees or there about.
Explanation / Answer
1. Below program does the sorting work.
import java.util.*;
public class ArrayListOfInteger {
public static void main(String args[]){
ArrayList<Integer> arraylist = new ArrayList<Integer>();
arraylist.add(11);
arraylist.add(2);
arraylist.add(7);
arraylist.add(3);
/* ArrayList before the sorting*/
System.out.println("Before Sorting:");
for(int counter: arraylist){
System.out.println(counter);
}
/* Sorting of arraylist using Collections.sort*/
Collections.sort(arraylist);
/* ArrayList after sorting*/
System.out.println("After Sorting:");
for(int counter: arraylist){
System.out.println(counter);
}
}
}
Output:
Before Sorting:
11
2
7
3
After Sorting:
2
3
7
11
To update the Categories of a JavaFX CategoryAxis():
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.