Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java Lab Exercise: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name private int ID;

java image text in transcribed
image text in transcribed
image text in transcribed
Lab Exercise: Implement the following classes: 1. class Course that includes two instance variables: private String Name; // the course name private int ID; // the course ID Your class should have the following: A constructor that initializes the two instance variables id and name Set and get methods for each instance variable. 2. class Department that includes three instance variables: private String deptName; private Course CRS[]; private int noof Courses; Your class should have the following: . a constructor that initializes the department name, set noofCourses and creates the array with size = noorCourses boolean exist(int) that checks whether the course object with id passed as parameter exists in the array or not. void addCourse (int, String) creates and adds the course if the course with id passed as parameter does not exist in the array. void deleteCourse (int) to delete a course if it exists in the array and displays a proper message. void printCourses() that prints the department name and all the courses in the array. void printCourses Recursively) that prints the department name and all the courses in the array recursively. (Hint: write an additional private helper method] Write the expected time and snare complexity as a comment at the void printCourses Recursively) that prints the department name and all the courses in the array recursively. (Hint: write an additional private helper method] Write the expected time and space complexity as a comment at the beginning of each method of your class. 3. Write a test application named Lab Test. In the main method, do the following: Input the department name and maximum number of courses then create a department object. Input the number of courses in the first set. Input the id and name of each course and add it to the department (Hint: Use a loop). Print the courses. Print the courses using the recursive method. Input the id of a course to be deleted. Delete the course. Print the courses. Input the id of a course to check if it exists and print a proper message Input the id and name of an additional set of courses and add them to the department (Hint: Use a loop). Print the courses. . stc KW LTE 9:25 PM kuwebcont.ku.edu.kw 10* 83% Sample Output Please enter the department name: Computer Engineering Department Please enter the maximum number of courses in the department: How many courses do you have? Enter course 1 id: 200 Enter course 1 nane! Ce Programming Enter course 2 id: 281 Enter course 2 name! Java Programming Enter course 3 id: 287 Enter course 3 nase: Data Structures Courses in Computer Engineering Department are: 1.200 C Programming 2. 201 Java Programming 3 - 207 Data Structures Using recursive print method.. Courses in Computer Engineering Department are: 1 - 200 C++ Programming 2 - 201 Java Programming 3.2e7 Data Structures Enter a course id to be deleted: 201 The course with the ID - 201 was deleted. Courses in Computer Engineering Department are: 1 - 2ee C++ Programming Enter a course id to search for: 201 The course with the ID - 201 does not exist in the department list How many additional courses do you have? Enter course 1 id: 210 Enter course 1 name: Computer Ethics Enter course 2 name: Fundamentals of Digital Logie Enter course 3 id: 300 Enter course 3 name: Design and Analysis of Algorithms Enter course 4 id: 325 Enter course 4 name: Human-Computer Interaction Courses in Computer Engineering Department are: 1 - 200 C++ Programming 2 - 21e Computer Ethics 3.2e7 Data Structures 4.262 Fundamentals of Digital Logic 5 - 30 Design and Analysis of Alcorithms 6 - 325 Human-Computer Interaction

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions