Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JAVA Hello, I would like help with this college program: College Program This exercise is open-resources (book, class programs, internet lookup). Your Task In this

JAVA Hello, I would like help with this college program: image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

College Program This exercise is open-resources (book, class programs, internet lookup). Your Task In this program you will demonstrate the use of inheritance by coding an abstract superclass and two subclasses. Here is a UML snapshot: Code the following three classes: Student (abstract superclass), Graduate (subclass, extends Student), and Undergraduate (subclass, extends Student). See next page for detailed specs. Follow the specs closely as you go. Student - Be sure to make this class abstract by using the keyword "ab stract". - Also make sure this class implements the Serializable interface. Required imports for this class: import java.io. Serializable; Private in stance variables: private string studentID; private string Ename; private String lname; private String major; Methods: Two constructors: 1) An empty/default ctor; 2) a 4-parameter ctor to initialize the private instance variables. Gets and sets for all instance variables. You may use the refactor >> encapsulate method to easily generate these. Override toString() method to produce the following line of sample data: 111111 Buffett, Warren Finance AThe student ID ("111111") is left-aligned (use minus sign) in a field 15 characters wide. The concatenated full name (use "LastName, FirstName" format as shown here) is left-aligned in a field 30 characters wide. The major is left-aligned in a field 15 characters wide. Two constructors: 1) An empty/default ctor; 2) a six-parameter ctor to receive the student ID, first name, last name, major, GRE score, and undergrachate GPA. Your constructor will explicitly call the superclass constructor, passing values for student D, first name, last name, and major to the super. The constructor will also initialize the GRE score and the undergraduate GPA here in this class. Override toStringo method Below, the two students highlighted in yellow are examples of graduate students. Your toString method will produce a single line of output to look like either of those two records: Note the first three data elements (student ID, name, and major) can be printed by calling super.toStringO. SAT scores do not apply to graduate students, so for that column you can hard-code "N/A" right-aligned in a field 10 characters wide. The GRE score is right-aligned in a field 15 characters wide. The undergrachate GPA is right aligned in a field 15 -characters wide and formatted to two decimal digits. Two constructors: 1) An empty/def ault ctor; 2) a six-parameter ctor to receive the student ID, first name, last name, major, SAT score, and high school GPA. Your constructor will explicitly call the superclass constructor, passing values for student D, first name, last name, and major to the super. The constructor will also initialize the SAT score and the high school GPA here in this class. Override toString0 method Below, the two students highlighted in yellow are examples of undergraduate students. Your toString method will produce a single line of output to look like either of those two records: Note the first three data elements (student ID, name, and major) can be printed by calling super toString .The SAT score is right-aligned in a field 10 characters wide. GRE scores do not apply to undergraduate students, so for that column you can hard-code "N/A" right-aligned in a field 15 characters wide. The high school GPA is right aligned in a field 15 -characters wide and formatted to two decimal digits. Main Method In your main class/method, create an ArrayList of type Student and populate the list with a mix of graduate and undergraduate students. Feel free to use the fake data shown here, using yourself as the fifth student. al1Studenta. add (new Graduate ("111111", "Warren", "Buffett", "Finance", 330, 3.95)); al1students, add (new Graduate ("222222", "Elon", "Musk", "Astrophysics", 340, 4.0)); al1Students, add (new Undergraduate ("333333", "He110", "Kitty", "Marketing", 1450, 3.4)) ; al1Studenta.add (new Undergraduate("444444", "Spongebob", "Squarepants", "Marine B1ology", 1200, 2.8)); al1students, add (new' Undergraduate ("555555", "Your Iirst", "Your last name", "MIs/Comp. Sc1", 1600, 4.0)): Loop through your ArrayList to produce the following output. If you coded your toString0 methods properly, your output should fall into place easily. If you're interested, here is the code I used for the column headers in the above output: Object Serialization Lastly, ask the user if he/she would like to save the student records to a file. If the answer is yes, serialize the entire ArrayList to a file called students.dat. You are not responsible for reading the serialized data back into the program in this exercise

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

Database Management An Organizational Perspective

Authors: Richard T. Watson

1st Edition

0471305340, 978-0471305347

More Books

Students also viewed these Databases questions

Question

Differentiate between common stock and preferred slock. LO1.

Answered: 1 week ago

Question

Identify the purpose of ratio analysis.

Answered: 1 week ago

Question

Differentiate the function. r(z) = 2-8 - 21/2 r'(z) =

Answered: 1 week ago