158k views
5 votes
Do the following code in java. Here is the prompt.The courses should fall into three disciplines: English, Math, and History. The superclass Course is given. Define the three subclasses English, Math, and History. Instead of getting information for one course, the program will get information for as many courses as the user wants.

All courses should have a unique CRN (numeric code), name, category (i.e. English, Math, or History).
English courses additionally have two attributes:
o level (lower, upper) o type can be either a reading or writing course or both.
Math courses have two additional attributes:
。 STEM or non-STEM (but not both)
o modality can be online, in person or hybrid courses
History courses have two additional attributes o Area E eligible or not o modality can be recorded, online, or in-person.
In starter code for Creating Courses.java, please complete one TODO in main and define three methods (see the starter code). The program does the following:
(1) Prompt the user to enter a sequence of courses through a loop and save all the courses in an array list.
(2) When user doesn't have more courses to enter, sort the courses by their category and then by CRN. You will need to implement the Comparable interface somewhere. (3) If the user didn't enter any course, the program should print "No courses entered." and
exit. Otherwise, proceed as follows:
a. Display all the courses.
b. Prompt user to enter a course name, search through the array list (when comparing, ignore case difference). If found, display "Course found." And then display the course. If not found, display "Course not found."

1 Answer

4 votes

Final answer:

The program requires creating subclasses for English, Math, and History under a Course superclass, entering course data into an array list, sorting them by category and CRN, and implementing search functionality.

Step-by-step explanation:

In a Java program to manage courses across multiple disciplines, a parent class named Course is given. The task involves creating three subclasses named English, Math, and History, each with unique attributes. Specifically, English courses have levels and types, Math courses distinguish between STEM and non-STEM and offer different modalities, while History courses are marked as Area E eligible or not and have various modalities.

The program should continuously prompt the user for course entries, storing them in an array list. Upon completion, the program must sort the courses by category and Course Registration Number (CRN) using the Comparable interface. If no courses are entered, the program prints "No courses entered." and exits. Otherwise, the courses are displayed, with functionality to search for a specific course by name, ignoring case differences, and display the result based on whether the course is found.

User Mdedetrich
by
9.0k points