Answered step by step
Verified Expert Solution
Link Copied!

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 257 Assignment 1
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 6
TA Marie Curie Physics 6
Professor Isaac Newton Calculus 4
Student Amy Adams Calculus 4
Student Will Smith Calculus 4
Student Brad Pitt Physics 6
Student Will Smith Physics 6
Professor Dmitri Mendeleev Chemistry 6
TA Carl Gauss Calculus 4
Student Amy Adams Economics 3
Professor Adam Smith Economics 3
TA Marie Curie Chemistry 6
Student Brad Pitt Chemistry 6
Student Will Smith Chemistry 6
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 >4 then lab hours =2, otherwise lab hours =1
lecture hours = total hours lab hours.
Therefore, in the following scenario:
Professor Isaac Newton Physics 6
TA Marie Curie Physics 6
Student Brad Pitt Physics 6
the professor has 4 hours, TA has 2, and the student has all 6.
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 (Professor/TA/Student) 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.splite("\\s+");

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

Students also viewed these Databases questions