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

I did not make my instructions clear when I asked for help on this exer earlier

ID: 3543479 • Letter: I

Question

I did not make my instructions clear when I asked for help on this exer earlier this evening:

The CollegeCourse "display()" method output should look like: For the course ict362 with 3 credits your cost will be $360.00

For the LabCourse, the "display()" method output should look like: The course bio241 is a lab with a $50.00 lab fee. With 3 credits your total cost will be $410.00

I can't seen to get my code right:   Pls Help


import java.util.Scanner;

public class UseCourse {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String labCourses = "BIO CHM CIS PHY";
        System.out.println("Please enter the course department:");
        String department = input.next();
        System.out.println("Please enter the courseNumber:");
        int courseNumber = input.nextInt();
        System.out.println("Please enter the number of credits:");
        int credits = input.nextInt();
        if (labCourses.indexOf(department.toUpperCase()) >= 0) {
            LabCourse course = new LabCourse(department, courseNumber, credits);
            course.display();
        } else {
            CollegeCourse course = new CollegeCourse(department, courseNumber,
                    credits);
            course.display();
        } // end if
    } // end main method
} //end class UseCourse

class LabCourse extends CollegeCourse {
    /* constructor for LabCourse class */

    public LabCourse(String department, int number, int credits) {
        super(department, number, credits);
        /* calling the super constructor with arguments */
        fee = fee + 50;/* adding 50$ to fee */
    }/* end of the constructor */
    /* display method to display all fields */


    public void display() {
        System.out.println("This course contains lab");
        System.out.println("department: " + department);
        System.out.println("number: " + number);
        System.out.println("credits: " + credits);
    }
}

class CollegeCourse {
    /* variable to hold department of course */

    String department;
    /* variable to hold number of course */
    int number;
    /* variable to hold credits of course */
    int credits;
    /* variable to hold fee of course */
    int fee;

    /* constructor for CollegeCourse class accepting arguments */
    public CollegeCourse(String department, int number, int credits) {
        /* assigning values to fields */
        this.department = department;
        this.number = number;
        this.credits = credits;
        this.fee = credits * 120;
        /* end of the constructor */
    }

    public void display() {

        System.out.println("This course does not contain lab");
        System.out.println("department: " + department);
        System.out.println("number: " + number);
        System.out.println("credits: " + credits);
        System.out.println("fee: " + fee);

//End of display//
//End of class//
    }
}

Explanation / Answer


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