Given main(), define a Course base class with methods to set and get the courseNumber and courseTitle. Also define a der

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Given main(), define a Course base class with methods to set and get the courseNumber and courseTitle. Also define a der

Post by answerhappygod »

Given main(), define a Course base class with methodsto set and get the courseNumber and courseTitle. Also define aderived class OfferedCourse with methods to set and getinstructorName, term, and classTime.
Ex. If the input is:
the output is:
CourseInformation.java
import java.util.Scanner;
public class CourseInformation { public static void main(String[] args) { Scanner scnr = new Scanner(System.in);
Course myCourse = new Course(); OfferedCourse myOfferedCourse = newOfferedCourse();
String courseNumber, courseTitle; String oCourseNumber, oCourseTitle,instructorName, term, classTime;
courseNumber = scnr.nextLine(); courseTitle = scnr.nextLine();
oCourseNumber = scnr.nextLine(); oCourseTitle = scnr.nextLine(); instructorName = scnr.nextLine(); term = scnr.nextLine(); classTime = scnr.nextLine();
myCourse.setCourseNumber(courseNumber); myCourse.setCourseTitle(courseTitle); myCourse.printInfo();
myOfferedCourse.setCourseNumber(oCourseNumber); myOfferedCourse.setCourseTitle(oCourseTitle); myOfferedCourse.setInstructorName(instructorName); myOfferedCourse.setTerm(term); myOfferedCourse.setClassTime(classTime); myOfferedCourse.printInfo();
System.out.println(" InstructorName: " + myOfferedCourse.getInstructorName()); System.out.println(" Term: " +myOfferedCourse.getTerm()); System.out.println(" Class Time: " +myOfferedCourse.getClassTime()); }}Course.java
public class Course{ // TODO: Declare private fields - courseNumber,courseTitle
// TODO: Define mutator methods - // setCourseNumber(),setCourseTitle()
// TODO: Define accessor methods - // getCourseNumber(),getCourseTitle()
// TODO: Define printInfo()}OfferedCourse.java
public class OfferedCourse extends Course { // TODO: Declare private fields - instructorName,term, classTime
// TODO: Define mutator methods - // setInstructorName(), setTerm(),setClassTime()
// TODO: Define accessor methods - // getInstructorName(), getTerm(),getClassTime()
}
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply