Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class named College Course that includes data fields that hold the depa

ID: 3780232 • Letter: C

Question

Create a class named College Course that includes data fields that hold the department (for example, MTH), the course number (for example, 102), the credits (for example, 4), and the fee for the course (for example, $175).

All of the fields are required as arguments to the constructor, except for the fee, which is calculated at $410 per credit hour.

Include a display () method that displays the course data.

Create a subclass named Lab Course that adds $75 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.

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.

Then display the course data.

Save the files as CollegeCourse.java, LabCourse.java, and UseCourse.java.

If possible would you be able to explain it to me. Thank you

Explanation / Answer

CollegeCourse.java

public class CollegeCourse{
    public String department;
    public int courseNumber;
    public double credits;
    public double fee;

    public CollegeCourse(String department, int courseNumber, double credits){
        this.department = department;
        this.courseNumber = courseNumber;
        this.credits = credits;
        this.fee = credits * 410;
    }

    public void display(){
        System.out.println("College Course Department: "+this.department+" Course Number: "+this.courseNumber+" Credits: "+this.credits+" Course Fee: "+this.fee);
    }
}

LabCourse.java

public class LabCourse extends CollegeCourse{

    public LabCourse(String department, int courseNumber, double credits){
        super(department, courseNumber, credits);
        this.fee += 75;
    }
    public void display(){
        System.out.println("Lab Course Department: "+this.department+" Course Number: "+this.courseNumber+" Credits: "+this.credits+" Course Fee: "+this.fee);
    }

}

UseCourse.java

import java.util.Scanner;
public class UseCourse{
    public static void main(String[] args) {
        System.out.print("Enter the department: ");
        Scanner sc = new Scanner(System.in);
        String department = sc.nextLine();
        if (department=="BIO" || department=="CHM" || department=="CIS" || department=="PHY"){
            System.out.print(" Course Number: ");
            int courseNumber = sc.nextInt();
            System.out.print(" Credits: ");
            double credits = sc.nextDouble();
            LabCourse labCourse = new LabCourse(department, courseNumber, credits);
            labCourse.display();
        }
        else{
            System.out.print(" Course Number: ");
            int courseNumber = sc.nextInt();
            System.out.print(" Credits: ");
            double credits = sc.nextDouble();
            CollegeCourse collegeCourse = new CollegeCourse(department, courseNumber, credits);
            collegeCourse.display();
        }
    }
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote