Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This HW is an extension from the HW10 last week and the ICE this week, and you should have three java files to start with:
- This HW is an extension from the HW10 last week and the ICE this week, and you should have three java files to start with: Students.java, Registration.java, and CrsSecs.java. In this HW, you will add constructors in the CrsSecs class, so we can create many pre-set course sections easily in the Registration class. When a series of course sections are listed, the user can enter the course ID to enroll in one of the course sections. If the course section is not found, the program will display a message "Invalid course ID. Try again." Otherwise, it will display a confirmation message "You are enrolled successfully." And the program will display the course list a gain to show the changes. Requirements: (25 pts) a) In the CrsSecs.java file, add the default constructor and a customized constructor that can set up course sections with their Course ID, Section Number, Credit Hours and Seat Limit. There is no need to preset the Current Enrollment Number here. This number will start from 0 for all course sections, and will be changed when students enroll to the course sections. b) In the Registration class, 1. Create an object array or array list to host course sections. If using array, for this HW, you can create a 10-element (i.e., the size or the length of the array is 10) array in the type of CrsSecs class. If using array list, it doesn't need to determine the size, or limited by a pre-set size. 2. You can create 3 CrsSecs objects using the customized constructor, and place them as the first 3 elements in the array. Use a pointer variable to record the index for the next available element for a new course section. Again, if using array list, you can simply add each object into the array list. 3. Similar to the HW10, you will display the course sections for the users to see all courses in a table. Now in this HW, of course there are more than 1 course section in this table. You can use a FOR loop to display all course sections in the array or the array list. If using array, make sure you use the pointer value to control the loop. If using array list, use the size() of the array list to control the loop. 4. Add a search method to search course sections by Course ID. ? This method should be added in the Registration class, separated from the main method. ? This method is a value-return method that return the found object's index number. ? If you are using array for the course sections, this method needs two parameters: 1) the array of objects for CrsSecs, and 2) the pointer value. If you are using array list, just need the array list as parameter. ? In the method, prompt to the user for an input of Course ID, like MIS350. ? Use FOR loop to go to each valid element in this array. If using array, the FOR loop should be stopped by the pointer value. If using array list, it is stopped by the size() of the array list. ? In the loop, use IF condition: if the user input course ID matches with (using equalsIgnoreCase()) the Course ID for the element object, return the index variable i. After searching through all valid course sections, if no matching Course ID is found, return -1 after the FOR loop block. 5. In the main method, also in the HW section, call the search method to get a returned index value. Use a while loop: when the returned index is -1, display the message "Cannot find this course. Try another course please." Only when the returned index is not -1, it will continue with the HW10 part - prompt to the user if they want to enroll to this course, etc.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started