EECS 2031 Software Tools, Winter 2014

Lab 7 (closed in labtest mode), for Thursday 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 handle input where the timestamps are not increasing (i.e., unsorted). Moreover, you have to handle weight records that are optionally given in pounds instead of kilograms.

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.

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

Hints:

Additional hints: