Question: Write a stand-alone Java application for a university enrollment system. In this Java program you have to create 4 classes: Driver, Student, Undergrad and Postgrad.
Write a stand-alone Java application for a university enrollment system.
In this Java program you have to create 4 classes: Driver, Student, Undergrad and Postgrad. Classes Undergrad and Postgrad are extended from class Student.
Class Student encapsulates: students name, the program name and the year of study. Class Undergrad is derived from Student and it encapsulates the number of courses taken and the average course cost. Class Postgrad is derived from Student and it encapsulates the type of degree (i.e. Master or PhD), the name of the research supervisor and the yearly price of supervision (Note: it is assumed that Postgrad students do not take courses).
The class Driver contains a first section in which one creates up to 500 objects of both Undergrad and Postgrad type, which are stored in an array of 500 Student references. You have to show just two lines of this section, in which you create:
- an Undergrad object which will encapsulate Tom Jones as student name, ITEC as program, 3 as year of study, 15 as number of courses and 750.0 as average course cost.
- a Postgrad object which will encapsulate Mary Smith as student name, History as program, 2 as year of study, PhD as type of degree, Jim Doyle as supervisor name and 2000.0 as the average yearly price of supervision.
Next the driver contains a loop where it calculates and display the money paid by each of the Student objects stored in the array during their studies. For this task both Undergrad and Postgrad should contain a method called moneyPaid(). In this loop the driver should display the students name, program, year of study (this information should be provided by a toString() method) and money paid. For instance for the Postgrad student Mary Smith it will display:
Mary Smith, History, year=2, paid=$4000.0
(4000 was calculated by multiplying 2000 with 2=the number of years of study)
Finally the driver will display just the names of the students who are in the 3rd year of study in the English program.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
