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 ?
-
You are presented with the following alphabetical list of selected items from the financial statements of Reitmans (Canada) Limited: Administrative...
-
You are considering a 10-year, $1,000 par value bond. Its coupon rate is 8%, and interest is paid semiannually. If you require an effective annual interest rate (not a nominal rate) of 7.1225%, how...
-
What do you think led mankind to embark upon the study of Artificial Intelligence? Which fields of study particularly fed into it? What human desires did the study of Artificial Intelligence seek to...
-
Neuro Instruments uses a manufacturing costing system with one direct-cost category (direct materials) and three indirect-cost categories: a. Setup, production order, and materials-handling costs...
-
A troublesome power generator fails randomly at an average rate of 6 times per year. Use the Poisson distribution to calculate the % probability that the number of failures in a period of 3 years...
-
XYZ is a calendar-year corporation that began business on January 1, 2020. For the year, it reported the following information in its current-year audited income statement. Notes with important tax...
-
Minority designers have been fashion waves for decades however many still have not become household names. Who is your favorite minority designer? 1. speak on why you chose this designer 2). Describe...
-
Discuss your reaction to the Bingwa case study in Box 6. 3. List all factors that, in your opinion, contributed to Bingwas change and rank them in order of importance. Use role-play to imagine a...
-
Why are issues important considerations in planning communication activities?
-
Investigate what kind of policy would be needed to reduce damages inflicted on future generations based on the economic experiment with externalities shown in Figure 2.1.4 of the Learning point....
-
Do you agree that organizations need to be aware of the potential impact of public policy on their operations? Why?
-
Can you think of examples of health communication interventions that seek to benefit and address the needs of vulnerable and underserved groups in your neighborhood, community, city, and country? If...
-
Complete the sections Building the Work Breakdown Structure (WBS), Scheduling the activities, and Allocating Resources. This will require you to complete an MS Project Schedule starting with the...
-
Hotel Majestic is interested in estimating fixed and variable costs so that the company can make more accurate projections of costs and profit. The hotel is in a resort area that is particularly busy...
-
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 two pulleys fixed to the shaft are loaded as shown. If the journal bearings at \(A\) and \(B\) exert only vertical forces on the shaft, determine the required diameter of the shaft to the nearest...
-
The shaft is supported by journal bearings at \(A\) and \(B\) that exert force components only in the \(x\) and \(z\) directions on the shaft. If the allowable normal stress for the shaft is...
-
The shaft is supported by bearings at \(A\) and \(B\) that exert force components only in the \(x\) and \(z\) directions on the shaft. If the allowable normal stress for the shaft is \(\sigma_{\text...
Study smarter with the SolutionInn App