EECS 2031 Software Tools, Winter 2014

Lab 7b (closed in labtest mode), for Tuesday section

Cellphones and other electronic devices must be off while you are in the lab.

Background Scenario

This lab uses the same bathroom scale data transmission scenario as lab2 to lab6. In this lab, you are building a solution relative to lab5. However, this time you have to adapt your solution to enable a command to delete all records for a given user ID. Moreover, you have to handle time stamps that are given in an minute/second format

In the following and for ease of reading, the changes relative to lab5 have been marked below with '***'. As before, each line of input contains the following information:

timestamp userID weight

There are one more space characters separating the three pieces of information, except that the userID itself may now contain one or more spaces (as in "1000 John Jack Smith 123.45"). The fields are defined as follows:

This protocol can be parsed deterministically, as the weight is the first numeric field after a sequence of text fields, e.g. as in timestamp userIDa userIDb userIDc userIDd weight and none of the parts of the userID can start with a digit or '.'.

Objective

Now create a new ANSI-C program that does the following.

Requirements

Your program must the input read line by line from standard input. For the purpose of this lab, you do not need to worry about numeric overflow. In other words, you can safely assume that timestamps are guaranteed to fit in 32 bit integers, and floating point numbers will fit into a ANSI-C float variable. You can also safely assume that there is always at least one (or more) space characters between the fields and between each part of the userID.
*** You can also safely assume that there will not be records with equal time stamps.

Here is an example input, also provided as a file, input.txt.

3600  godzilla's kid 30.0
36000 godzilla 299
-1 godzilla's     kid 30.0
36001 godzilla's kid 30.1
600m2 godzilla's  kid 30.2
46002 godzilla's       kid 30.1
46999 godzilla     30.1
60000 john jack       andrew wolfgang jiang rami      tom bob robert frank richa
rd smith 123.5
500000 godzilla's       kid 60
1000000 godzilla's       kid 100
3000000 godzilla's kid 300
5000000 godzilla's kid 89
If you start your program with this, you should get the following output, also provided as a file, expectedoutput.txt.
OK newuser
OK newuser
Deleted user
OK newuser
Suspiciously large weight change
OK
Suspiciously large weight change
OK newuser
OK
OK
OK
OK
|     * 
|     * 
|     * 
|     * 
|     * 
|     * 
|     * 
|    ** 
|   ****
|*******
+-------

Hints:

Additional hints: