Name it Assignment21 Write the Java source code necessary to
Name it \"Assignment_2_1\".
Write the Java source code necessary to build a solution for the problem below:You have just taken a new \"Teach for America\" job in a very rural, impoverished neighborhood. The school system does not provide you with any tools. You decide to write a new gradebook program. You need your new gradebook to allow you to sort the students by NAME or by highest grade on a test so that you can fill out all of the many district reports on your students\' progress. Remembering that sometimes Java lets you write one method and use it many times, you decide to write a generic method that will return the maximum and minimum element in a two-dimensional array (your gradebook, NAME, SCORE). Test the program using an array of random integers and again using an array of random names.
In order to do the comparison of names you need to understand the Java Character encoding scheme (Links to an external site.).
 You should check this site to understand which character is bigger (\"A\" or \"Z\") and then work from there.
Print the array sorted by SCORE, then use it again and print the array sorted by NAME.
| Step 1 Create a new project. Name it \"Assignment_2_1\". Step 2 Build a solution. Write the Java source code necessary to build a solution for the problem below:You have just taken a new \"Teach for America\" job in a very rural, impoverished neighborhood. The school system does not provide you with any tools. You decide to write a new gradebook program. You need your new gradebook to allow you to sort the students by NAME or by highest grade on a test so that you can fill out all of the many district reports on your students\' progress. Remembering that sometimes Java lets you write one method and use it many times, you decide to write a generic method that will return the maximum and minimum element in a two-dimensional array (your gradebook, NAME, SCORE). Test the program using an array of random integers and again using an array of random names. In order to do the comparison of names you need to understand  the Java Character encoding scheme (Links to an external  site.). Print the array sorted by SCORE, then use it again and print the array sorted by NAME. Step 3 Compile and execute your code. | 
Solution
================GradeBook=======
 // Grade book using two-dimensional array to store grades.
public class Teach_for_America
 {
 private String Name; // name of course this grade book represents
 private int grades[][]; // two-dimensional array of student grades
 
 // two-argument constructor initializes Name and grades array
 public Teach_for_America( String name, int gradesArray[][] )
 {
 Name = name; // initialize Name
 grades = gradesArray; // store grades
 } // end two-argument Teach_for_America constructor
// method to set the course name
 public void setName( String name )
 {
 Name = name; // store the course name
 } // end method setName
// method to retrieve the course name
 public String getName()
 {
 return Name;
 } // end method getName
// display a welcome message to the Teach_for_America user
 public void displayMessage()
 {
 // getName gets the name of the course
 System.out.printf( \"Welcome to the grade book for\ %s!\ \ \",
 getName() );
 } // end method displayMessage
// perform various operations on the data
 public void processGrades()
 {
 // output grades array
 outputGrades();
// call methods getMinimum and getMaximum
 System.out.printf( \"\ %s %d\ %s %d\ \ \",
 \"Lowest grade in the grade book is\", getMinimum(),
 \"Highest grade in the grade book is\", getMaximum() );
// output grade distribution chart of all grades on all tests
 outputBarChart();
 } // end method processGrades
// find minimum grade
 public int getMinimum()
 {
 // assume first element of grades array is smallest
 int lowGrade = grades[ 0 ][ 0 ];
// loop through rows of grades array
 for ( int studentGrades[] : grades )
 {
 // loop through columns of current row
 for ( int grade : studentGrades )
 {
 // if grade less than lowGrade, assign it to lowGrade
 if ( grade < lowGrade )
 lowGrade = grade;
 } // end inner for
 } // end outer for
return lowGrade; // return lowest grade
 } // end method getMinimum
// find maximum grade
 public int getMaximum()
 {
 // assume first element of grades array is largest
 int highGrade = grades[ 0 ][ 0 ];
// loop through rows of grades array
 for ( int studentGrades[] : grades )
 {
 // loop through columns of current row
 for ( int grade : studentGrades )
 {
 // if grade greater than highGrade, assign it to highGrade
 if ( grade > highGrade )
 highGrade = grade;
 } // end inner for
 } // end outer for
return highGrade; // return highest grade
 } // end method getMaximum
// determine average grade for particular student (or set of grades)
 public double getAverage( int setOfGrades[] )
 {
 int total = 0; // initialize total
 
 // sum grades for one student
 for ( int grade : setOfGrades )
 total += grade;
// return average of grades
 return (double) total / setOfGrades.length;
 } // end method getAverage
// output bar chart displaying overall grade distribution
 public void outputBarChart()
 {
 System.out.println( \"Overall grade distribution:\" );
// stores frequency of grades in each range of 10 grades
 int frequency[] = new int[ 11 ];
   
 // for each grade in Teach_for_America, increment the appropriate frequency
 for ( int studentGrades[] : grades )
 {
 for ( int grade : studentGrades )
 ++frequency[ grade / 10 ];
 } // end outer for
   
 // for each grade frequency, print bar in chart
 for ( int count = 0; count < frequency.length; count++ )
 {
 // output bar label ( \"00-09: \", ..., \"90-99: \", \"100: \" )
 if ( count == 10 )
 System.out.printf( \"%5d: \", 100 );
 else
 System.out.printf( \"%02d-%02d: \",
 count * 10, count * 10 + 9 );
 
 // print bar of asterisks
 for ( int stars = 0; stars < frequency[ count ]; stars++ )
 System.out.print( \"*\" );
System.out.println(); // start a new line of output
 } // end outer for
 } // end method outputBarChart
// output the contents of the grades array
 public void outputGrades()
 {
 System.out.println( \"The grades are:\ \" );
 System.out.print( \" \" ); // align column heads
// create a column heading for each of the tests
 for ( int test = 0; test < grades[ 0 ].length; test++ )
 System.out.printf( \"Test %d \", test + 1 );
System.out.println( \"Average\" ); // student average column heading
// create rows/columns of text representing array grades
 for ( int student = 0; student < grades.length; student++ )
 {
 System.out.printf( \"Student %2d\", student + 1 );
for ( int test : grades[ student ] ) // output student\'s grades
 System.out.printf( \"%8d\", test );
// call method getAverage to calculate student\'s average grade;
 // pass row of grades as the argument to getAverage
 double average = getAverage( grades[ student ] );
 System.out.printf( \"%9.2f\ \", average );
 } // end outer for
 } // end method outputGrades
 } // end class Teach_for_America




