Question
LANGUAGE: JAVA Modify the code Source Code: import java.util.*; public class StudentRecordsViaParallelArrays { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) {
LANGUAGE: JAVA
Modify the code
Source Code:
import java.util.*; public class StudentRecordsViaParallelArrays { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { String[] id; // Array that will store ID numbers String[] names; // Array that will store names String[] course;// Array that will store courses int[] yearLevel; // array that will store year levels int count; // variable that will store the number of students byte[] pGrade; // to store prelim grade byte[] mGrade; // to store m1dterm grade byte[] tFGrade; // to store tentative Final Grade byte[] fGrade; // to store final grade // Read the number of students to be recorded from the keyboard System.out.print("How many student records will be created? "); count = Integer.parseInt(keyboard.nextLine()); // Instantiate the arrays such that each will have a length=size id = new String[count]; names = new String[count]; course = new String[count]; yearLevel = new int[count]; pGrade = new byte[count]; mGrade = new byte[count]; tFGrade = new byte[count]; fGrade = new byte[count]; //Invoke the method that will fill the arrays with elements populateArrays(id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); // Show the students following the order by which they were entered System.out.println("Original Order Data"); showData(id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); // Invoke the method for displaying the array elements // Invoke the method that will sort the arrays in parallel sortDataBasedOnNames2(id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); // Invoke the method for displaying the array elements // Show the students in sorted order System.out.println("Sorted Data"); showData(id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); } /** * Put elements into arrays (parallel arrays) for ID numbers, names, course, year levels, prelim grade, * m1dterm grade, tentative final grade, and final grade **/ public static void populateArrays(String[] id, String[] n, String[] c, int[] y, byte[] p, byte[] m, byte[] t, byte[] f) { for (int index = 0; index Note: Read the comment section for the requirement of this activity. /** * Student Records Keeping Using Parallel Arrays ** An ID number, a name, a course, a year level and others are * attributed to a student. Hence, eight arrays are * used: An array that stores ID numbers, an array that * stores names, an array that stores courses, an array * that stores year levels, etc. The eight arrays are treated * as parallel arrays such that the first elements of the * eight arrays are actual attributes (ID number, name, course, year level, etc.) of one student, the second elements are * actual attributes of another student, and so on. *
*
* REQUIRED: * Complete and show a sample run (sample output) of the following program. **/ import java.util.*; public class Student RecordsViaParallelArrays { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { String[] id; // Array that will store ID numbers String[] names; // Array that will store names String[] course; // Array that will store courses int[] yearLevel; // array that will store year levels int count; // variable that will store the number of students byte[] pGrade; // to store prelim grade byte[] mGrade; // to store midterm grade byte[] tFGrade; // to store tentative Final Grade byte[] fGrade; // to store final grade // Read the number of students be recorded from the keyboard System.out.print("How many student records will be created? "); count = Integer.parseInt(keyboard.nextLine()); to // Instantiate the arrays such that each will have a length=size id = new String[count]; names = new String[count]: course = new String[count]; yearLevel = new int [count]; pGrade = new byte[count]; mGrade = new byte[count]; tFGrade = new byte[count]; fGrade = new byte[count]; //Invoke the method that will fill the arrays with elements populateArrays (id, names, course, yearLevel, pGrade, mGrade, tFGrade, Grade); // show the students following the order by which they were entered System.out.println("Original Order Data"); showData(id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); // Invoke the method for displaying the array elements // Invoke the method that will sort the arrays in parallel sortDataBasedonNames 2 (id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); // Invoke the method for displaying the array elements // Show the students in sorted order System.out.println("Sorted Data"); showData (id, names, course, yearLevel, pGrade, mGrade, tFGrade, fGrade); } /** names, * Put elements into arrays (parallel arrays) for ID numbers, course, year levels, prelim grade, * midterm grade, tentative final grade, and final grade **/ public static void populateArrays (String[] id, String[] n, String[] c, int[] y, byte[] p, byte[] m, byte[] t, byte[] f) { for (int index = 0; index
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started