I have an array assignment that I am stuck on. This is the assignment. This is my first time posting here, but I have gained alot of information from the other posts.
Create a program that asks the user how many students there are. Then, for each student, ask for a student id, the first name, last name, and score (must be between 0 and 100 to be valid). When all the data has been entered, calculate and display the average. Allow the user to search for a student by entering a student id. If the student id is valid and a student is found, display the student's full name, score, and deviation of the score from the average. If the student has the highest score, display a message indicating that. Continue asking the user to search for students until the user enters "quit", at which point the program should exit.
The following is the code I have so far. I am not sure how to search the arrays and also how to return all the information from the different arrays.
import java.util.Scanner; public class Assn06 { public static void main(String[] args) { Scanner input = new Scanner(System.in); // User input number of students System.out.print("Enter the number of students"); int studentNumber=input.nextInt(); int sum = 0; // Array for student ID int[] studentid = new int[studentNumber]; String[] firstname = new String[studentNumber]; String[] lastname = new String[studentNumber]; int[] studentscore = new int[studentNumber]; int i; for ( i = 0 ; i < studentNumber ; i++) { studentscore[i] = studentid[i]; firstname[i] = lastname[i]; System.out.printf("Enter student %d ID : ", i+1); int studentId = input.nextInt(); studentid[i] = studentId; System.out.printf("Enter student %d first name : ", i+1); String studentFirstname = input.next(); firstname[i] = studentFirstname; System.out.printf("Enter student %d last name : ", i+1); String studentLastname = input.next(); lastname[i] = studentLastname; System.out.printf("Enter student %d score : ", i+1); int studentScore = input.nextInt(); studentid[i] = studentScore; sum += studentScore; } //Calculate Average int average = sum / studentNumber; //Display Average System.out.println("The student average is " + average); // Search by student Id System.out.printf("Search for student by entering ID: "); int studentIdsearch = input.nextInt(); public static int linearSearch(studentid, studentIdsearch) { for (int j = 0 ; j < list.length; j++) { if (studentIdsearch == list[j]) return j; } } } }