Question: how can I finish this code ? public class CreateCourses { public static void main ( String [ ] args ) { Scanner keyboard =
how can I finish this code public class CreateCourses
public static void mainString args
Scanner keyboard new ScannerSystemin;
ArrayList courses new ArrayList;
TODO : write a while loop that iterates until user enters N when asked whether they have a course to enter.
Within the loop, call the method getACourse, and add the course to the arraylist courses.
System.out.printlnDo you have a course to enter YN;
String answer keyboard.nextLine;
while answerequalsY
need to call the getACourse method
add the returned course to the array list course
System.out.printlnDo you have a course to enter YN;
answer keyboard.nextLine;
if coursessize
System.out.printlnNo courses entered.";
return;
printCoursescourses;
System.out.printlnEnter a course name to search:";
String name keyboard.nextLine;
Course c searchCoursecourses name;
if c null
System.out.printlnCourse found.";
System.out.printlnc;
else
System.out.printlnCourse not found.";
getACourse method will prompt user to enter the information of a course,
create the course, and return the course. If the userentered category is
incorrect, the method should return null.
@param keyboard the scanner that will be used to extract user inputs
@return the course created or null if the course category user enters is incorrect.
public static Course getACourseScanner keyboard
TODO : complete the method definition
System.out.printlnEnter CRN number:";
System.out.printlnEnter course category:";
System.out.printlnEnter course name:";
return null;
printCourses will print the courses stored in an array list.
@param list the array list that contains the courses
public static void printCoursesArrayList list
TODO : define the method
need loop
searchCourse will search the array list for a course of a given name
@param list the array list that contains the courses
@param name a course name
@return the course with the name. If not found, return null.
public static Course searchCourseArrayList list, String name
TODO : define the method
need loop
return null;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
