Question: Write a method that will return a list of students expected to graduate in a particular year. The user will be prompted for and enter

Write a method that will return a list of students expected to graduate in a particular year.

The user will be prompted for and enter a number of students in the school. The program should then prompt for and read names and graduation years of each student. These will be stored into two separate arrays.s The array names will hold the full name of each student. The array gradYear will hold the corresponding graduation year for the student in the same element of the names array.

Important: You can assume there will never be more than 100 students so both arrays can be declared to hold 100 elements of the type (String or int).

Implement a method called listGraduates whose prototype should be:

public static String[] listGraduates(String[] names, int[] gradYears, int yearOfGrad, int elementCount)

The two arrays hold the data collected about each student. The third argument is the graduation year to search for, and the final argument is the count of valid elements in the names and gradYears arrays. The method should only process that many elements of each array.

It will build and return a list of names in a string array. The string array will have 1 element for each student. At the end of the array, there should be a sentinel value (this is a value that is not valid for the data expected). As a sentinel, use the string 0.

The main procedure should use the console to prompt the user and read the names of each student and their graduating year. It will build the two arrays described above and then call listGraduates. When listGraduates returns a String array with the graduating students, then main should print the names, one per line. The main will know the end of valid data when it reaches a name that is 0.

Example run:

Enter number of students: 8

Student name: Joseph Cool

Graduating year: 2019

Student name: Jane Doe

Graduating year: 2020

Student name: Beth Good

Graduating year: 2019

Student name: Tanner McPherson

Graduating year: 2018

Student name: Terry Able

Graduating year: 2019

Student name: Susan Anspach

Graduating year: 2018

Student name: Trent Kearny

Graduating year: 2020

Student name: Nancy Galt

Graduating year: 2018

List for which year? 2019

Graduating Students:

Joseph Cool

Beth Good

Terry Able

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!