Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

LANGUAGE: JAVA Modify the code Source Code: // Example of a Reference Class public class Student { private String firstName = ; private String midName

LANGUAGE: JAVA

Modify the code

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Source Code:

// Example of a Reference Class public class Student { private String firstName = ""; private String midName = ""; private String lastName = ""; private int age; private double gPA; /** * Constructs a student named Adel Man Tamano, 39 years old and with 95.0 grade point average. */ public Student() { firstName = "Adel"; midName = "Man"; lastName = "Tamano"; age = 39; gPA = 95.0; } /** * Constructs a student with first name f, middle name m, last name l, age a and grade point average gpa. */ public Student(String f, String m, String l, int a, double gpa) { firstName = f; midName = m; lastName = l; age = a; gPA = gpa; } /** * Returns the first name of the student */ public String getFirstName() { return firstName; } /** * Returns the last name of the student */ public String getLastName() { return lastName; } /** * Returns the middle name of the student */ public String getMidName() { return midName; } /** * Returns the age of the student */ public int getAge() { return age; } /** * Returns the grade point average of the student */ public double getGPA() { return gPA; } /** * Sets the first name of the student to fName */ public void setFirstName(String fName) { firstName = fName; } /** * Sets the last name of the student to lName */ public void setLastName(String lName) { lastName = lName; } /** * Sets the middle name of the student to mName */ public void setMidName(String mName) { midName = mName; } /** * Sets the age of the student to a */ public void setAge(int a) { age = a; } /** * Sets the grade point average of a student to g */ public void setGPA(double g) { gPA = g; } /** * Returns a string showing the name, age and grade point average of a student */ public String toString() { return (firstName + " " + midName + " " + lastName + "," + age + "," + gPA); } /** * Returns true if this student is the same as student other else it returns false. **/ public boolean equals(Student other) { boolean r = false; r = (firstName.equalsIgnoreCase(other.getFirstName())); //improve this part return r; } }

________________________________________________________________________________________

// Example of a class that uses the Student Class (Reference Class) import java.util.Scanner; public class StudentList { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { Student[] list; int number; System.out.print("How many students will be listed? "); number = Integer.parseInt(keyboard.nextLine()); list = new Student[number]; System.out.println("Enter the student information."); for (int x = 0; x  0) minIndex = y; } if (minIndex != x) { temp = s[x]; s[x] = s[minIndex]; s[minIndex] = temp; } } } // end of sortList method } // end of class

Required: Create a similar application program. Include appropriate data members for your Student class (i.e. modify the given examples). Show a sample output of your application. First Approach: Use parallel arrays Second Approach: Use an array (one dimensional array) of objects Parallel Arrays Arrays that are processed in parallel because the elements are associated First Name Middle Name Last Name Age Grade Point Average Juan Mark Anne Carla Abad Lee Dimo Park Cruz Kuan Lopez Somi 24 25 23 24 91.25 92.30 90.87 88.90 Formulating Record Structure Using Java A record is composed of fields. A field is an attribute of a record. Create a class that will serve as a template for a record (Reference Class) The class variables of a Reference Class define the attributes/fields. o The Student class shown below is an example of a Reference class. As illustrated, the attributes of a student are firstName, midName, lastName, age and gPA. The Reference Class may be used in any program (another class). The StudentList class shown below is an example of a class that uses the Student class. // Example of a Reference Class public class Student { private String first Name private String midName = ""; private String lastName = ""; private int age; private double gPA; /** * Constructs a student named Adel Man Tamano, 39 years old and with 95.0 grade point average. */ public Student() { firstName = "Adel"; midName = "Man"; lastName = "Tamano"; age = 39; GPA = 95.0; } /** * Constructs a student with first name f, middle name m, last name 1, age a and grade point average gpa. public Student (String f, String m, String 1, int a, double gpa) { firstName = f; midName = m; lastName = 1; age = a; GPA = gpa; } /** * Returns the first name of the student */ public String getFirstName() { return firstName; } /** * Returns the last name of the student */ public String getLastName() { return lastName; } /** * Returns the middle name of the student */ public String getMidName() { return midName; } /** * Returns the age of the student */ public int getAge() { return age; } /** * Returns the grade point average of the student */ public double getGPA() { return GPA; } /** * Sets the first name of the student to fName */ public void setFirstName(String fName) { firstName = f Name; } /** * Sets the last name of the student to Name */ public void setLastName(String Name) { lastName = 1 Name; } /** * Sets the middle name of the student to mName */ public void setMidName(String mName) { midName = mName; } /** * Sets the age of the student to a public void setAge(int a) { age = a; } /** * Sets the grade point average of a student tog public void set GPA (double g) { GPA = 9; } /** * Returns a string showing the name, age and grade point average of a student */ public String toString() { return (firstName + + midName + lastName + age + + GPA); } 11 /** * Returns true if this student is the same as student other else it returns false. **/ public boolean equals(Student other) { boolean r = false; r = (firstName.equalsIgnoreCase(other.getFirstName()); // improve this part return r; } } } // Example of a class that uses the Student Class (Reference Class) import java.util.Scanner; public class StudentList { static Scanner keyboard = new Scanner(System.in); public static void main(String[] args) { Student[] list; int number; System.out.print("How many students will be listed? "); number = Integer.parseInt(keyboard.nextLine()); list = new Student[number ]; System.out.println("Enter the student information."); for (int x = 0; x 0) minIndex = y; } if (minIndex != x) { temp = s[x]; s[x] = s[minIndex]; s[minIndex] = temp; } } } // end of sortlist method } end of class Discussions Creating a Reference Class Composition of a class class { 0) minIndex = y; } if (minIndex != x) { temp = s[x]; s[x] = s[minIndex]; s[minIndex] = temp; } } } // end of sortlist method } end of class Discussions Creating a Reference Class Composition of a class class {

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_2

Step: 3

blur-text-image_3

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

Pro Database Migration To Azure Data Modernization For The Enterprise

Authors: Kevin Kline, Denis McDowell, Dustin Dorsey, Matt Gordon

1st Edition

1484282299, 978-1484282298

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago