// "Records2" class. import hsa.Console; public class Records2 { static Console c = new Console(); void sortbyName(Pair[] sr) { int j = 0; int i = 0; Pair temp = new Pair(); //... if (sr[i].name.compareTo (sr[j].name) < 0)//comparing the name part of the pair j = j;//just to compile temp = sr[i];// this will take one pair from the array and store that pair in temp //... } void sortbyGPA(Pair[] sr) { int j = 0; int i = 0; i=i; //... if(sr[i].gpa < sr[j].gpa)//compare the grade part of the pair i = i; //... } void showResults(Pair[] sr) { } public static void main (String[] args) { int i = 0; final int SIZE = 50; Pair[] studentrecords = new Pair[SIZE]; //initialize the array of pairs for (i=0; i<50; i++)//initialize all the pairs { studentrecords[i]=new Pair();//initialize one pair } for (i=0; i<3; i=i+1) //read in the pairs { c.println("Enter a name followed by the gpa."); studentrecords[i].name = c.readLine();//each pair has a name studentrecords[i].gpa = c.readDouble();//each pair has a gpa } for (i=0; i<3; i++) //print out the records, keeping names and grades on the same line { c.print(studentrecords[i].name + " " + studentrecords[i].gpa); c.println(); } } // main method public static class Pair { //set up each pair to have a name and its associated gpa. String name; double gpa; public Pair () { name = new String(); gpa = 0.0; } } } // Records2 class