The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
Write a program that displays information about the Computer Science semester schedule. Your program will require two Java files: your main program and a Course class. The Course class must contain the following class instance data:Â
data example Course number GEEN163 CRN 20781 Instructor’s last name Williams Days the course is taught MWF Start time of the class 1000 Room where the class will be held Graham210 Title of the course Intro to Computer ProgrammingÂ
All of the data should be represented as strings. Your class must include a constructor method that initializes all of the data values. This class should not have a main method. The only additional method required is: public void printCourse() which should display the information about the course. You may format the output in any way that works.Â
In a separate class, the main program should read the file CScourses.txt and create a Course object for each course in the file. Each line of data in the file has the course information in the same order as shown above. Except for the title of the class, all of the data is one word separated by white space. Your program should read the data values using the Scanner method next() except for the title where it should use nextLine().Â
As your program reads each line of the file, the Course object should be put into a hash table. A hash table is a data structure that allows you to retrieve information based on a key. Your program will put the Course objects in the table using the course number as the key. You will need to create a hash table object at the beginning of your program withÂ
java.util.HashMap<String,Course> hashTable = new java.util.HashMap<>();Â
You can put data into the hash table using the put method and retrieve data using the get method. The put method has two parameters, the key and the object to be put in the hash table. The get method has only one parameter, the key to be used to find the corresponding object. To put the data in the hash table useÂ
Course csCourse = new Course( courseNumber, crn, other parameters ); hashTable.put( courseNumber, csCourse);Â
Â
After your program has read all of the data from the file, it should ask the user to enter a course number (such as GEEN163) from the keyboard. It should then use the get method to find the data in the hash table and display the information. The get method will return the Course object with the given course number. Call the printCourse method on the returned object to display the course information. If the get method does not find a class in the hash table with that number, it will return null. Your program must check if the returned value is equal to null and, if it is, display a message indicating there is no such class.Â
EnteredNumber = keyboard.next(); Course found = hashTable.get( EnteredNumber ); if (found == null ) {Â // if course is not in the tableÂ
The program should continue asking the user for course numbers until END is entered. Â Â