HW0 Qualification Assignment

Goals: The point of this assignment is to see if you are ready for CS310. It will exercise your knowledge of Java, the command line, and working with an arbitrary data structure that you cannot modify.

Story behind the data: Your company has a server and there are 500 PC stations whose filesystem resides on it, numbered 1 through 500 inclusive. Every 10 minutes the system appends to a log file the PC numbers and user name of the person currently logged on, one PC number and username per line of text. (Not all stations are in use at every moment). A fragment of the log file looks like this:

... ......
9 ALTEREGO
12 ROOT
433 JOECOHEN
433 USERMGR
12 WHEEL
433 JOECOHEN
354 ROOT
... ...

This log file shows JOECOHEN was on PC station 433 twice but USERMGR was on that station at an intervening time. It also shows that ROOT was on station 12 at one time and station 354 later on. You will generate fake data to test your submission.

Write a program in Java that meets the following specifications:

1. The program will read from standard in and not a file. Assume IO redirection when your program is invoked, so it must be read from System.in rather than by actually opening a named text file. User names are ASCII (plain text) strings with no embedded whitespace and a maximum length of 40 characters.

2. Print data about PC station usage: a header line and then one line of output for each PC showing the PC station number, the most common user of that station (in the event of a tie, choose one user), and a count of how many times that user was on that PC station. Here is sample output:

Line, Most Common User, Count
1, OPERATOR, 174983
2, HANNIBAL, 432
3, -NONE-, 0
4, SYSMGR, 945
., ..., ...

3. Data structures: You must use SinglyLinkedList.java to hold all the information about one PC. Do not modify this class, but instead, wrap it in another class “LineUsageData”. Although normally we would use a JDK LinkedList or other JDK container for this, for the qualifier the essential thing is to check that you know how to work with any reasonable Java classes.

4. Design and implement a class “Usage” to hold a (username, count) pair, and a class “TermReport” for the top-level code. Usage can be a nested class of TermReport, or a top-level class. An object of type LineUsageData holds all the data for one particular PC station, and has methods addObservation(String username) and Usage findMaxUsage(). TermReport.java should be decomposed into methods; including a main().

Find SinglyLinkedList.java in the hw0 folder here: https://github.com/ieee8023/cs310-summer2016

To Deliver

Turn in the code for classes Usage, TermReport, and LineUsageData. Your program should be complete and compile. Note: Since the purpose of this exercise is to determine whether you are prepared for this course you should not discuss the material with anyone else. (Later in the term we will encourage these discussions.)

Your code must compile with the following command:

$javac -cp . Usage.java TermReport.java LineUsageData.java SinglyLinkedList.java and run with the following command (Make your own users.log): $java -cp . TermReport < users.log

If you choose to you can also use the Sedgewick stdlib.jar classes to help you. You must then include the jar file and your code most compile and run using the following command. No other jar files are allowed.

$javac -cp .:stdlib.jar Usage.java TermReport.java LineUsageData.java SinglyLinkedList.java$java -cp .:stdlib.jar TermReport < users.log