EECS 2031 Software Tools, Winter 2014

Lab 2 (open lab, not in labtest mode)

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

Background Scenario

One common usage scenario for smartphones is to monitor the status of the user as it changes over time. Imagine that every time you weigh yourself, the data is stored on the "smart" bathroom scale. Using Bluetooth technology, the scale can the then transfer all recent measurements to your smartphone, whenever it is on and the smartphone is in range. That enables the smartphone to show a graph of weight changes over time and other visualizations to the user. In this lab, we are going to implement a simple parser that deals with a set of data coming from such a smart scale. Such data could be transferred in a simple text format.

Here we will deal with such input, consisting of individual measurement record, one per line. Each line contains the following information:

timestamp userID weight

There is a single Space character separating the 3 pieces of information. The fields are defined as follows:

Objective

What to do

First, create a new directory for this lab 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 overflow. In other words, you can safely assume that timestamps are guaranteed to fit in 32 bit integers, userID's will not be longer than 31 characters, and floating point numbers will fit into a ANSI-C float variable. You can also safely assume that there is always a single space characters between the fields. Moreover, each line of input is guaranteed to be less than 99 characters long.

Assuming that the program is started with lab2, and given the following input, which is also provided for convenience as a file input.txt:

Testing 234 234.153
1235 Mega0123test -x-0.5
3600 godzilla 300
36000 godzilla 299
36001 godzilla 200
1000 innocent 69
your program should create the following output:
Invalid time
Illegal weight
OK
OK
Suspiciously large weight change
Nonmonotonic timestamps

Hints: