In starter code for CreatingCourses java, please complete one TODO in main and define three methods...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these programming questions
-
Your task is to build upon your calendar from Assignment 1 to fix a few things and add more functionality to your program. (****************************************** HERE IS ASSIGNMENT 1 THAT WE ARE...
-
Who was the highest paid athlete in sports in the 1 9 9 0 s ?
-
The Mountain Biking Corp. opened on April 1. The following selected events and transactions occurred during April: Apr. 1 Issued common shares for $100,000 cash. 3 Purchased an out-of-use ski hill...
-
Refer to Problems 1.13 and 1.14. If Marjatta Viitasalos utility costs remain constant at $500 per month, labour at $8 per hour, and cost of ingredients at $0.35 per loaf, but Viitasalo does not...
-
What is the purpose of timelines in an investigation?
-
Helix Company produces costumes used in the television and movie industries. Recently the company received an ongoing order for Samurai robes to be worn in an upcoming Japanese historical action...
-
Find a HAMILTONIAN PATH of the graph below (Give a sequence of letters to describe the path (e.g. A, D, E, B, A etc.) B E F G Paragraph B I UA Lato (Recom... v 19px... v L > Ea 5 0
-
The owner of Panda's Pizza Inc. has had some financial challenges in recent months and has asked you to do some financial analysis. Round to the nearest penny. Given the financial information...
-
Soho Inc. is considering an investment that has an expected return of 22.5% and a standard deviation of 8%. What is the investment's coefficient of variation?
-
A stock had returns of 16.27 percent, 24.18 percent, ?12.29 percent, and 9.62 percent over four of the past five years. The arithmetic average return over the five years was 13.28 percent. What was...
-
Evaluate f(-10), (1), f(10) for the following picewise function f(t). Find domain,range and sketch the graph of the given function: f(t)= = t-4, t>4 8-2t, t < 4.
-
You invested $100,000 into an account 25 years ago. The investment is now worth $350,000. Calculate the interest rate if the investment was compounded semi-annually.
-
Glenview Hospital currently has six surgical suites including two Da Vinci robots. The director of surgery is proposing a capital investment in an additional robot. The director has gathered data to...
-
why is it essential for businesses to be concerned with safety of their workers
-
Refer to the situation described inBE 18-13, but assume a 2-for-1 stock split instead of the 5% stock dividend. Prepare the journal entry to record the stock split if it is to be effected in the form...
-
Calculate the amount of the child and dependent care credit allowed for 2012 in each of the following cases, assuming the taxpayers had no income other than the stated amounts. a. William and Carla...
-
Emily Jackson (Social Security number 765-12-4326) and James Stewart (Social Security number 466-74-9932) are partners in a partnership that owns and operates a barber shop. The partnership's first...
-
Abigail (Abby) Boxer is a single mother working as a civilian accountant for the U.S. Army. Her Social Security number is 676-73-3311 and she lives at 3456 Alamo Way, San Antonio, TX 78249. Helen,...
-
The IT implementation project is bogging down and falling behind schedule. The department heads are complaining that the project cannot help them if it is not implemented in a reasonable time frame....
-
This isnt what I need! objected the admissions officer at Northwest Regional Hospital. Judy sighed, But this is the software you asked us to create for you. I dont care what I said at the time, this...
-
Assume the network diagram shown in Figure 11.19. Megan is responsible for activities A and C. Use the critical chain methodology to resource-level the network. What are two options for redrawing the...
Study smarter with the SolutionInn App