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

In the Grade Reprot programing example, we created the classes Course and Studen

ID: 3535337 • Letter: I

Question

In the Grade Reprot programing example, we created the classes Course and Student, and in the main program we created an array to hold student data. Redo the Grade Report programming example by defining the class Student List with an instance variable to hold students' data,an instance variable to store the number of students, and an instance variable to store the tuition rate. This class contain methods to load students' data in t array and output grade reports and the appropriate constructors. The method main in an separate class uses the class StudentList to create grade reports. Also, write a program to test your class.

Explanation / Answer

ANSWER

Try the following and know if thats what you meant. The code is still a mess but it has the most vital functionality.

/*

* To change this template, choose Tools | Templates

* and open the template in the editor.

*/

/**

*

* @author admin

*/

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;

}

}