Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In starter code for CreatingCourses java, please complete one TODO in main and define three methods (see the starter code). The program does the

  
student submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available belowstudent submitted image, transcription available below

 

In starter code for CreatingCourses java, please complete one TODO in main and define three methods (see the starter code). The program does the following: (1) Prompt the user to enter a sequence of courses through a loop and save all the courses in an array list. (2) When user doesn't have more courses to enter, sort the courses by their category and then by CRN. You will need to implement the Comparable interface somewhere. (3) If the user didn't enter any course, the program should print "No courses entered." and exit. Otherwise, proceed as follows: a. Display all the courses. b. Prompt user to enter a course name, search through the array list (when comparing, ignore case difference). If found, display "Course found." And then display the course. If not found, display "Course not found." n No courses entered. Sample run 2: Do you have a course to enter (Y/N)? Enter CRN number: 1000 Enter course category: Math Enter course name: Pre Calc Is this a STEM course (true/false)? true Is this course an (online), an (in-person), or a (hybrid) course? online Do you have a course to enter (Y/N)? Y Enter CRN number: 1001 Enter course category: English Enter course name: Composition II Please enter course level (lower or upper): lower Is the English course a reading course (R), a writing course (W), or both (RW)? W Do you have a course to enter (Y/N)? Enter CRN number: 500 Enter course category: English Enter course name: Composition I Please enter course level (lower or upper): lower Is the English course a reading course (R), a writing course (w), or both (RW)> W Do you have a course to enter (Y/N)? Sorted courses by category and then by CRN: Course [crn-500, name-Composition I, category English] English (level-lower, type-w] Course (crn-1001, name Composition II, category-English] English [level-lower, type-W] Course [crn-1000, name-Pre Calc, category-Math] Math [stem true, type-online] Enter a course name to search: Pre Calc Course found. Course [crn-1000, name-Pre Calc, category Math] Math [stem-true, type-online] 67 9 10 11 12 13 14 1usages public class Course { 3 usages private int 3 usages private String and 3 usages private String Category no usages I public Course (int crn, String name, string category) this.crn crn; this.name name; this.category category; 15 a 19 22 24 20 25 29 30 31 of 35 no usages public int getcrn(){return crn;} no usages public String getName() { return name; no usages public String getCategory() return category; @Override + public String toString() return "Course [crne crn", name name +, category" + category + } -)-; public class CreateCourses { 3 usages 7 1 usage 8 9 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 6 29 public static void main(String[] args) Scanner keyboard new Scanner(System.in); ArrayList courses new ArrayList (); / 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. System.out.println("Do you have a course to enter (Y/N)?"); String yesorNo keyboard.nextLine(); while (yesorNo.equalsIgnoreCase(anotherStrings "y")) { Course c getACourse (keyboard); if (c = null) { } courses.add(c); System.out.println("Do you have a course to enter (Y/N)?"); yesorNo keyboard.nextLine(); if (courses.size() == 0) { System.out.println("No courses entered."); return; 30 31 } 32 33 34 35 36 /* TODO: sort the array List 34 35 36 37 38 TODO: sort the array List System.out.println("Sorted courses by category and then by CRN:"); printCourses (courses); System.out.println("Enter a course name to search: "); String name keyboard.nextLine(); Course c searchCourse (courses, name); if (c!= null) { System.out.println("Course found."); System.out.println(e); } else { 39 40 41 42 43 44 45 40 47 48 40 } 50 51 52 53 System.out.println("Course not found."); 54 55 getAcourse method will prompt user to enter the information or a course, create the course, and return the course. If the user-entered category is incorrect, the method should return null. * @param keyboard the scanner that will be used to extract user inputs 56 . 57 58 59 60 0 * @return the course created or null if the course category user enters is incorrect. 1 usage public static Course getACourse (Scanner keyboard) { 62 63 0 } 332 333 35 35 65 66 67 70 //TODO: replace the following statement with an actual implementation of the method return null; 1. printcourses will print the courses stored in an array List. @param List the array list that contains the courses 1 usage public static void printCourses (ArrayList list) { 3 4 5 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. */ 3 usages I public static Course searchCourse (ArrayList list, String name) { //TODO: replace the following statement with an actual implementation of the method return null; G 27 c) English.java 1 String Utilities javax Coursejava x G CreateCourses Java English javax 15 I

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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

Who was the highest paid athlete in sports in the 1 9 9 0 s ?

Answered: 1 week ago