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

Create a class named CollegeCourse that includes data fields that hold the depar

ID: 3691335 • Letter: C

Question

Create a class named CollegeCourse that includes data fields that hold the department (for example, ENG), the course number (for example, 101), the credits (for example, 3), and the fee for the course (for 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. 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

Explanation / Answer

Answer for Question:

Step 1:
Created the class for UseCourse:

import javax.swing.JOptionPane;

public class UseCourse
{   
public UseCourse()
{
CollegeCourse college;
// Collect all the necessary data first to determine whether it is a lab course or not.
String dept = JOptionPane.showInputDialog(null, "Enter Department");

String courseNumString = JOptionPane.showInputDialog(null, "Enter Course Number");
int courseNum = Integer.parseInt(courseNumString);

String credString = JOptionPane.showInputDialog(null, "Enter Credits");
int cred = Integer.parseInt(credString);

// Now that we have the info we can ask the question.
if (dept.equals("BIO") | dept.equals("CHM") | dept.equals("CIS") | dept.equals("PHY"))
{college = new LabCourse(dept, courseNum, cred);}

else {college = new LabCourse(dept, courseNum, cred);}
college.display();
}

public static void main(String[] args)
{new UseCourse();}
}

Step 2: Created class for CollegeCourse

import javax.swing.JOptionPane;
public class CollegeCourse {

protected String dept;
protected int courseNum;
protected int cred;
protected int fee;
protected int Charge = 120;
protected int labfee;

public CollegeCourse(String dept, int courseNum, int cred)
{
this.dept = dept;
this.courseNum = courseNum;
this.cred = cred;
fee = cred * Charge;
}

public void display(){

JOptionPane.showMessageDialog(null, dept + courseNum +
" Non-lab Course" + " " + cred +" Credits" + " Total fee is $" + fee);
}
}

Step 3: Created the class for LabCourse


import javax.swing.JOptionPane;
public class LabCourse extends CollegeCourse
{
public LabCourse(String dept, int courseNum, int cred)
{super(dept, courseNum, cred);}

public void display()
{
fee += 50;
JOptionPane.showMessageDialog(null, dept + courseNum +
" Lab Course" + " " + cred +" Credits" + " Total fee is $" + fee);
}
}

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