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

In this assignment, you will design and code a simple Java application that defi

ID: 3743419 • Letter: I

Question

In this assignment, you will design and code a simple Java application that defines a class, instantiates the class into a number of objects, and prints out the attributes of these objects in a specific way.


The requirements of this application are as follows: The application is to define a Java class called Course. The Course class has the following attributes: 1. code - a string field to store the course code (e.g. IT1006) 2 creditHours-an int field to store the credit hours of the course (e.g. 6) The application then instantiates, in order, seven instances (objects) from the Course class and assigns to each instance the following values: Order of Course Object code attribute IT1006 Course Object creditHours attribute instantiation IT4782 IT4789 IT4079 IT2230 IT3345 IT2249 2 3 6 6 Finally, the application prints out, in the same order as the instantiation order, the attributes of these instances using this format: [order of instantiation] Course Code (Course Credit Hours) Successful completion of this assignment will show the correct order of object instantiation and the correct attributes of each object when the application is run. Your program output should look like this sample output

Explanation / Answer

class Course
{
   static int count=0;
   Course()
   {
       System.out.println("Cource Object each has a code(e.g IT1006) and credit hours(e.g 6) The Number inside the [] is the Display Number The Number inside in () is the credit hours for the Course ");
   }
   Course(String code, int creditHors)
   {

       System.out.println("["+count+"]"+code+"("+creditHors+")");
       count+=1;
   }

  
}

class main
{
   public static void main(String args[])
   {

       String code;
       int creditHors;

       Course obj0 = new Course();

       code = "IT1006";
       creditHors = 6;
       Course obj1 = new Course(code, creditHors);

       code = "IT4782";
       creditHors = 3;
       Course obj2 = new Course(code, creditHors);
      
       code = "IT189";
       creditHors = 3;
       Course obj3 = new Course(code, creditHors);

       code = "IT4079";
       creditHors = 6;
       Course obj4 = new Course(code, creditHors);

       code = "IT2230";
       creditHors = 3;
       Course obj5 = new Course(code, creditHors);

       code = "IT3345";
       creditHors = 3;
       Course obj6 = new Course(code, creditHors);
  
       code = "IT2249";
       creditHors = 6;
       Course obj7 = new Course(code, creditHors);
   }

}

Thank you.