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

To learn how to instantiate and process an array of objects. Create a new folder

ID: 3650391 • Letter: T

Question

To learn how to instantiate and process an array of objects. Create a new folder called assign12 under C:JSPchapter 1. Define a new class called Course(save in a file called course. java), with class attributes as follows: coursed (String) courseTitle (String) creditHours (int) The default constructor (should set courseid =, "courseTitle = " ",creditHours = 0) The "init" constructor (input Parameters: courseId,courseTitle, creditHours ) Write a test driver called TestCourse. java that instantiates an array of course objects with the following details 1st element: courseid = "CS101", courseTitle "Introductory computer science," creditHours = 3 2nd element: courseid "CS102", courseTitle = "Data strectures," creditHours =3 3rd element: courseid = "CS103", courseTitle = "C++ Programming," creditHour = 4 The test driver should then display the list of courses offered as follows. (Don't worry about the formatting and columnar alignment. )

Explanation / Answer

Please rate...

Program Course.java

============================================================

class Course
{
    String courseId;
    String courseTitle;
    int creditHours;
    Course()
    {
        courseId="";
        courseTitle="";
        creditHours=0;
    }
    Course(String cID,String cT,int cH)
    {
        courseId=cID;
        courseTitle=cT;
        creditHours=cH;
    }
    public String getCourseId()
    {
        return courseId;
    }
    public String getCourseTitle()
    {
        return courseTitle;
    }
    public int getCreditHours()
    {
        return creditHours;
    }
}

=============================================================

Program CourseTest.java

=============================================================

class CourseTest
{
    public static void main(String args[])
    {
        Course c1=new Course("CS101","Introductory Computer Science",3);
        Course c2=new Course("CS102","Data Structures",3);
        Course c3=new Course("CS103","C++ Programming",4);
        System.out.println("********************************************");
        System.out.println(" Courses Offered");
        System.out.println("********************************************");
        System.out.println("Course ID Course Title Credit Hours");
        System.out.println("---------------------------------------------");
        System.out.println(c1.getCourseId()+" "+c1.getCourseTitle()+" "+c1.getCreditHours());
        System.out.println(c2.getCourseId()+" "+c2.getCourseTitle()+" "+c2.getCreditHours());
        System.out.println(c3.getCourseId()+" "+c3.getCourseTitle()+" "+c3.getCreditHours());
        System.out.println("*********************************************");
    }
}

==============================================================

Sample output:

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