Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi I how would I approach this problem using inheritance. Exercise Problem Inheritance Use the Scanner class for all input and prin9() to format output.

Hi I how would I approach this problem using inheritance.

image text in transcribed
Exercise Problem Inheritance Use the Scanner class for all input and prin9() to format output. Create a Student class with string a/ributes name, and id and integer numCredits. Include mutators and accessors for each a/ribute and two constructors; parameterized constructor -- uses mutators to set the a/ribute values. default constructor - calls the parameterized constructor with default values. Class Student will need two public methods. The rst method is calcTuition and simply returns 0.0. The second is toString that uses the accessor methods to get the a/ribute values and returns student info as a single, forma/ed string for output as shown below. Create a second class named Undergrad that extends Student. Add an integer a/ribute for yearLevel (1- 4) plus o. the mutator and accessor methods for this new a/ribute. While a default constructor is not required, a full parameterized constructor with four arguments is required with calls the parent class parameterized constructor and a call to the mutator for yearLevel. Add two public methods. calcTuition that returns the product of numCredits and the undergraduate cost per credit hour ($517 - should be implemented as a constant). toString that returns the parent Student info as well as the yearLevel in a single, forma/ed string shown below. Create a third class named Grad that extends the Student class. Add a String a/ribute for researchArea o. the mutator and accessor methods. Include a default constructor that uses the mutator for researchArea. A parameterized constructor is not needed for this class. Add two public methods. calcTuition that returns the product of numCredits and the graduate cost per credit hour ($713 - should be a constant). toString returns the parent student info as well as the research area in a single, forma/ed string for output as shown in the sample below. Finally, create a StudentTest class with a main method. In the main method, prompt the user to enter a student type using a menu system as shown in the sample run below. For Undergrad students, create the object using the full-parameterized constructor object. For Grad students, create the object using the default constructor and the mutator methods. Store both Student types in an ArrayList of Students named enrollment. Once the user is done entering students, run through the arraylist using a for/each loop. Each Ume, print out the type of student, the results of a single call to a toString method, and the results of a call to the calcTuition method. Be sure the output is forma/ed as shown in the example. Use System.out.printf or String.format to align the output. Sample Execu=on

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

Modern Dental Assisting

Authors: Doni Bird, Debbie Robinson

13th Edition

978-0323624855, 0323624855

Students also viewed these Programming questions

Question

write for loop that display the following set of numbers

Answered: 1 week ago