Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

CPSC 131: Introduction to Computer Programming II
Program 3: Inheritance and Interface
1 Description of the Program
In this assignment, you will make two classes, Student and Instructor, that inherit from a
superclass Person. The implementation of class Person is given. You will also need to write
a test program to test the methods you write for these two classes. The implementation
details are described as follows.
Stage 1: In the first file Student.java, you should include the following additional instance
variables and methods (other than all instance variables and methods inherited from class
Person):
• Private instance variables studentID, and major;
• A constructor takes four inputs (name, age, studentID and major);
• Two additional getter methods to return each of instance variables (accessor);
• Two setter methods to change each of instance variables (mutator);
• A method toString that converts a student’s information into string form. The
string should have the format as shown in Figure 1. You should override superclass
toString() method.
• A method compareTo that implements the interface Comparable, so that Student
objects can be sorted by studentID in an ascending order.
Stage 2: In the second file Instructor.java, you should include the following additional
instance variables and methods (other than all instance variables and methods inherited
from class Person):
• Private instance variable salary;
• A constructor takes three inputs (name, age, and salary);
• One additional getter method to return the instance variable (accessor);
• One setter method to change the instance variable (mutator);
1
• A method toString that converts an instructor’s information into string form. The
string should have the format as shown in Figure 1. Specifically, you need to format
salary value to 2 decimal places, and make them right aligned. You should also
override superclass toString() method.
• A method compareTo that implements the interface Comparable, so that Instructor
objects can be sorted by salary in an ascending order.
Stage 3: In the third file PersonTester.java, you will need to do the followings:
1. You need to read data file “data1.txt” into an array of Student objects, Specifically,
(a) The first number in the first line of the file is used to determine the array size.
(b) The remaining lines are the student records. You will need to create a Student
object using each line’s information, and put it into the array.
2. Do sorting of the initialized array of Student objects, and then print them out. The
outputs should be nicely labeled and formatted, as shown in Figure 1.
3. Repeat the above steps to read data file “data2.txt” into an array of Instructor
objects, do sorting and print them out. The outputs should be nicely labeled and
formatted, as shown in Figure 1. To avoid code redundancy, you may use a loop to
handle the repetitive procedure.

al Taminal wedo Frogeni .Cone
Ophone
A List of students sorted by studentID:
Name: Eric
Name: Larry
Age: 19
ID: 11111
Major: Engineering
Age: 20
ID: 12345
Major: CPSC
Name: John
Age: 17
ID: 23434
Major: CPSE
Name: Jennifer Age: 20
ID: 33333
Major: Biology
Age: 23
Name: Christina Age: 19
Name: Amy
ID: 34343
Major: IT
ID: 55555
Major: French
Name: Mike
Name: Ashley
Age: 21
ID: 77777
Major: Chemistry
Age: 18
ID: 99923
Major: ENGL
A List of instructors sorted by salary:
Name: Jenny
Age: 29
Salary:
35343.00
Name: Kathy
Age: 45
Salary:
39888.43
Name: Chris
Age: 35
Salary:
46233.00
Name: Alex
Age: 42
Salary:
55599.21
Name: Steve
Age: 50
Salary:
98000.50
Name: Shala
Age: 55
Salary: 150010.23
expand button
Transcribed Image Text:al Taminal wedo Frogeni .Cone Ophone A List of students sorted by studentID: Name: Eric Name: Larry Age: 19 ID: 11111 Major: Engineering Age: 20 ID: 12345 Major: CPSC Name: John Age: 17 ID: 23434 Major: CPSE Name: Jennifer Age: 20 ID: 33333 Major: Biology Age: 23 Name: Christina Age: 19 Name: Amy ID: 34343 Major: IT ID: 55555 Major: French Name: Mike Name: Ashley Age: 21 ID: 77777 Major: Chemistry Age: 18 ID: 99923 Major: ENGL A List of instructors sorted by salary: Name: Jenny Age: 29 Salary: 35343.00 Name: Kathy Age: 45 Salary: 39888.43 Name: Chris Age: 35 Salary: 46233.00 Name: Alex Age: 42 Salary: 55599.21 Name: Steve Age: 50 Salary: 98000.50 Name: Shala Age: 55 Salary: 150010.23
Expert Solution
Check Mark
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education