Create a class named CollegeCourse that includes data fields that hold the depar
ID: 3734693 • Letter: C
Question
Create a class named CollegeCourse that includes data fields that hold the department (example ENG), the course number (example 101), the credits (example 3) and a fee for the course (example $360). All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $120 per credit hour. Include a display) method that displays the course data. Create a subclass named LabCourse that adds $50 to the course fee. Override the parent class display) method to indicate that the course is a lab course and to display all the data. Write an application named UseCourse that prompts the user for course information. It may be better if you provide with choices for the user. If the user enters a class in any of the following departments, create a LabCourse: BIO, CHM, CIS, or PHY If the user enters any other department, create a CollegeCourse that does not include the lab fee. Display the course data in a readable format. Submit a minimum of 3.java files (CollegeCourseXXX.java, LabCourseXXX.java, UseCourseXXX.java where XXX denotes your last name followed by first initial)Explanation / Answer
Answer.)
CollegeCourseXXX.java
package com.example;
public class CollegeCourseXXX {
protected String department;
protected int courseNumber;
protected int credits;
protected int feeOfTheCourse;
//parent class parameterized constructor to initialize the instance variables
public CollegeCourseXXX(String department, int courseNumber, int credits) {
super();
this.department = department;
this.courseNumber = courseNumber;
this.credits = credits;
}
//Display method to display all the details
public void display(){
System.out.println("Department : "+department);
System.out.println("Course Numer : "+courseNumber);
System.out.println("Credits : "+credits);
this.feeOfTheCourse=(credits*120);
System.out.println("Course Fees : $"+feeOfTheCourse);
}
}
LabCourseXXX
package com.example;
public class LabCourseXXX extends CollegeCourseXXX{
//Parent class super constructor to load parent class instance variables
public LabCourseXXX(String department, int courseNumber, int credits) {
super(department, courseNumber, credits);
}
@Override
//Display method to display the details in sub class
public void display(){
System.out.println("Course is a Lab course.");
System.out.println("Department : "+department);
System.out.println("Course Numer : "+courseNumber);
System.out.println("Credits : "+credits);
feeOfTheCourse=(credits*120)+50;
System.out.println("Course Fees : $"+feeOfTheCourse);
}
}
Output 1 : (Non lab department)
Choose any course : (1-7)
1. BIO
2. CHM
3. CIS
4. PHY
5. ENG
6. ACC
7. FRE
7
Department : FRE
Course Numer : 203
Credits : 3
Course Fees : $360
Output 2 : (Lab department)
Choose any course : (1-7)
1. BIO
2. CHM
3. CIS
4. PHY
5. ENG
6. ACC
7. FRE
1
Course is a Lab course.
Department : BIO
Course Numer : 102
Credits : 5
Course Fees : $650
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.