Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In this assignment, you will draw grades of students as a horizontal bar chart,

ID: 3728934 • Letter: I

Question

In this assignment, you will draw grades of students as a horizontal bar chart, as shown in Figure 1 and 2. Your program will load input data from a text file. Input data contains student names and exam grades for students. Sample input data files (student_info1.txt and student_info2.txt) are shown in Box 1 and Box 2. Input data files start with an integer value denoting the number of exams. For instance, for the first data file -student_info1.txt-, there are five exam grades. In the second file, there are three exams. Total grade of each student can be maximum 100. Your program will read a single file at each run, and plot grades for all students found in the input data file. Design your algorithm in such a way that if you change the input file, it should adjust the parameters of the bar charts so that all student data fits into a figure window. For instance, you need to compute the height of rectangles according to the number of students in the input files. As can be seen from Figures 1 and 2, rectangle heights are bigger for nine students found in the second data file. In these examples, figure dimensions are W:1500xH:800. You may adjust figure dimensions according to your screen resolution. You should store students in a Student array. The UML class diagram of Student class is shown in Figure 3. Name data field is private. Student grades are stored in the public grades array. You should automatically create grades array according to the number of exams, provided in the input data files. Note that in each data file, exam numbers are different. Tip: Create grades array in the second constructor.

Fig1

Fig2

Please help me about this assignment. if you attach mentioned java classes it will mean so much to me. Thanks

Student Grades 51 100 Joselyn 73 Genevieve 53 Marcos Hendrix 57 Kinsley 95 Evie 62 Carlos Chace 27 51 Scarlett 69 Ben Jayden Morgan Pamela 38 70

Explanation / Answer

import java.util.Scanner;

class StudentList {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.print("Enter number of students: ");

int numOfStu = input.nextInt();

int[] grades = new int[numOfStu];

String[] names = new String[numOfStu];

for (int i = 0; i < numOfStu; i++) {

String name = input.next();

int grade = input.nextInt();

names[i] = name;

grades[i] = grade;

System.out.println("");

}

//this is the area that sorts it from least to greatest

//i is the indexed value of the last number in array

//if it's 10 numbers big, i is 9

//loop ends before index 0 because 0 should be in it's place at the end already

for (int i = grades.length - 1; i > 0; i--) {

//resets both to 0 to start at the beginning of the array

//so that you can test the new first number

int currentMax = grades[0];

int currentMaxIndex = 0;

//finds largest number out of all up to back-limit

//i is back-limit that gets chopped off by one each time

for (int k = 1; k <= i; k++) {

if (currentMax < grades[k]) {

currentMax = grades[k];

currentMaxIndex = k;

}

}

//after largest number is found, assign that number to i

//i is a high number like 9, then 8, then 7, etc.

//each time it runs, i-- so each second highest max number

//gets put infront of the all time highest number

grades[currentMaxIndex] = grades[i];

grades[i] = currentMax;

String tempName = names[currentMaxIndex];

names[currentMaxIndex] = names[i];

names[i] = tempName;

}

for(int i=0; i<grades.length; i++)

System.out.println(names[i] + " " + grades[i]);

}

public static int[] reverseInt(int[] array) {

int[] poop = new int[array.length];

for (int i = 0, j = poop.length - 1; i < array.length; i++, j--) {

poop[j] = array[i];

}

return poop;

}

public static String[] reverseString(String[] array) {

String[] poop = new String[array.length];

for (int i = 0, j = poop.length - 1; i < array.length; i++, j--) {

poop[j] = array[i];

}

return poop;

}

}