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

intro to comp sci, this is question part 3 part one: https://www.chegg.com/homew

ID: 3665439 • Letter: I

Question

intro to comp sci, this is question part 3

part one: https://www.chegg.com/homework-help/questions-and-answers/intro-comp-sci-writing-coursejava-q10340895

part two: https://www.chegg.com/homework-help/questions-and-answers/intro-comp-sci-question-part-two-part-one-https-wwwcheggcom-homework-help-questions-answer-q10353573

5.1 GENERAL DESCRIPTION you will expand on your CourseListQ2 class to incorporate more advanced features. 5.2 MoRE HELPFUL COURSELIST METHODS Create a duplicate of your CourseList02.java file, and name it CourseListQ3.java. (You do not need to prefix it with your name this time.) Name the class appropriately to match. You have been provided with a main program file, called TestA103.java. You do not need to create a copy of your original Question 1 Course Java file. Define a getcoursesByDept (String) method that accepts a String parameter representing a department. This method should return a CourseListQ3 object containing any Courses in your list that are offered by the specified department Define a method called getCoursesByTerm (int). This method should return a CourselistQ3 object containing any Courses in your list whose term matches the given integer. Define a void method called removeListofcourses (CourseListQ3). This method should delete all courses in the argument list. Use the removeCourse method to perform the actual delete all courses in the argument list Use the removeCourse method to perform the actual deletions not need to create a copy ot your original Question 1 Course Java tile. Define a getcoursesByDept (String) method that accepts a String parameter representing a department. This method should return a CourseListQ3 object containing any Courses in your list that are offered by the specified department Define a method called getCoursesByTerm (int). This method should return a CourselistQ3 object containing any Courses in your list whose term matches the given integer. Define a void method called removeListofcourses (CourseListQ3). This method should delete all courses in the argument list. Use the removeCourse method to perform the actual delete all courses in the argument list Use the removeCourse method to perform the actual deletions

Explanation / Answer


public class TestALQ3 {

   /**
   * @param args
   */
   public static void main(String[] args) {
       // TODO Auto-generated method stub
      
       CourseListQ2 list=new CourseListQ2();
       list.addCourse(new Course("Natural Resource","Geography",1,2));
       list.addCourse(new Course("Real-Time Systems ", "Comp Sci", 2, 4));
       list.addCourse(new Course("Culture and Environment", "Geography", 3, 2));
       list.addCourse(new Course("Aristotle", "Philosopshy", 2, 2));
       list.addCourse(new Course("Design in Engineering", "Engineering", 3, 1));
       list.addCourse(new Course("Literary Topics", "English", 3, 1));
       list.addCourse(new Course("Structure and Modelling", "Chemistry", 1, 1));
       list.addCourse(new Course("Finite Element Analysis", "Engineering", 2, 3));
       list.addCourse(new Course("Plant and Animal Physiology", "Agriculture", 1, 2));
       list.addCourse(new Course("Biomachinery", "Biosystems", 3, 4));
       list.addCourse(new Course("Health and Disease", "History", 1, 4));
       list.addCourse(new Course("Ethics and Biomedicine", "Philosophy", 3, 2));
       list.addCourse(new Course("Programming Language Concepts", "Comp Sci", 3, 3));
      
       printList(list);
       System.out.println("Cancelling courses offered by Emgineering and Geography...");
       list.removeListOfCourses(list.getCoursesByDept("Engineering"));
       printList(list);

   }

   private static void printList(CourseListQ2 list) {
       // TODO Auto-generated method stub
       int len=list.numberOfCourse;
       System.out.println("There are "+len+" Courses available");
       int i=0;
      
       while(len!=0){
           if(list.courses[i]!=null){
           String trm="";
           if(list.courses[i].getTerm()==1)
               trm="Winter";
           else if(list.courses[i].getTerm()==2)
               trm="Spring";
           else if(list.courses[i].getTerm()==3)
               trm="Fall";
           System.out.println("CRN: "+list.courses[i].getCRN()+", Term:"+trm+", "+list.courses[i].getCoursseTitle()+", Dept: "+list.courses[i].getDeptName()+
                   " (year"+list.courses[i].getProgramYear()+")");
           len--;
           i++;
           }
          
          
       }
      
      
   }

}