Answered step by step
Verified Expert Solution
Question
1 Approved Answer
CENG 2 5 7 Assignment 1 Goals Practice abstract classes & polymorphism Description A college department needs a system for obtaining total hours for all
CENG Assignment
Goals
Practice abstract classes & polymorphism
Description
A college department needs a system for obtaining total hours for all the people involved in its program. They have a record of all the professors, teaching assistants and students with the name of the course and total hours for each course following this pattern:
Professor Isaac Newton Physics
TA Marie Curie Physics
Professor Isaac Newton Calculus
Student Amy Adams Calculus
Student Will Smith Calculus
Student Brad Pitt Physics
Student Will Smith Physics
Professor Dmitri Mendeleev Chemistry
TA Carl Gauss Calculus
Student Amy Adams Economics
Professor Adam Smith Economics
TA Marie Curie Chemistry
Student Brad Pitt Chemistry
Student Will Smith Chemistry
end
Out of all hours for each course, the professor attends only lecture hours, TA conducts lab hours and students must attend all hours.
The number of lab and lecture hours is based on the total hours of the course:
if total hours then lab hours otherwise lab hours
lecture hours total hours lab hours.
Therefore, in the following scenario:
Professor Isaac Newton Physics
TA Marie Curie Physics
Student Brad Pitt Physics
the professor has hours, TA has and the student has all
Write a program using abstract classes to represent people and a proper class hierarchy to represent professors, TAs and students. The program should scan the full record above from standard input all at once do NOT prompt the user to enter each line or data piece separately and do not hard code the record and produce a printout of all the people with their total hours through the use of polymorphism. Every person must be mentioned in the printout only once. The printout should be of the following format:
Title ProfessorTAStudent FirstName LastName TotalHours
Do not use ArrayList or any other Java Collections class.
Note, there are tabs in the record above, make sure to use regular expression s in split method or as a delimiter in Scanner object:
String tokens line.splites;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started