Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that implements array. Follow all the Coding standards such as commenting, indentation, defensive programming etc. mentioned in Coding Standard Handout in moodle.

Write a program that implements array. Follow all the Coding standards such as commenting, indentation, defensive programming etc. mentioned in Coding Standard Handout in moodle. Your program name should be Student.java . The program should use two arrays stuName and stuGpa of type String and double respectively. In the main method, define the length or size of both arrays as SIZE_ARR of 30. Read the student name and gpa from the input file using sentinel loop. You need to create two methods 1. public static int seqSearch(int numRecords, String[] stuName, double[] stuGpa, String nameKey, double gpaKey) { // Write the sequential search that compares both name, and gpa. // Only when both are correct return that index otherwise return -1. // this index will be used to find out position of the key in the array in the main method. } 2. public static void printData(int numRecords, String[] stuName, double[] stuGpa) { // Write a loop that prints out all the record you read in. // Use the format shown in the sample output. } Here the first method performs the sequential search to find a record and the second record prints the result. You need to pass two arrays in both methods as arguments. In method 1, nameKey is the search key for the student and stuGpa is the search key for that student's GPA. If both the student name and gpa matches, then only it will return the index of array. If not, it will return -1. In method 2, you need to print the record as shown in sample output. Your input file should look like Tom 4.0 Bob 3.2 Jack 2.5 Jill 4.0 Carry 3.5 Kylie 3.2 EndData Jenny 2.4 Kylie 3.2 Jack 4.0 Bob 3.2 EndData Here, EndData represents the sentinel value. The input values before first EndData is student records and the input values after the first EndData are search keys. For the sample input, your output should look like: The name of the student in location 0 is Tom and has a gpa of 4.0. The name of the student in location 1 is Bob and has a gpa of 3.2. The name of the student in location 2 is Jack and has a gpa of 2.5. The name of the student in location 3 is Jill and has a gpa of 4.0. The name of the student in location 4 is Carry and has a gpa of 3.5. The name of the student in location 5 is Kylie and has a gpa of 3.2. The student: Jenny with a gpa of 2.4 was not found in the array. The student: Kylie with a gpa of 3.2 was found in the array at position 5. The student: Jack with a gpa of 4.0 was not found in the array. The student: Bob with a gpa of 3.2 was found in the array at position 1. 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions