ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 29 May 2017 My Price 8.00

Course number GEEN163 CRN 20781

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.   

Answers

(11)
Status NEW Posted 29 May 2017 04:05 AM My Price 8.00

-----------

Not Rated(0)