Name: _______________________
Section: _____
Mini"quiz" #5
Tuesday, Oct. 22, 2002
A tiny temperature sensor in a bird's nest transmit a temperature value every 0.1 second. The value is a byte whose value is the temperature (Celsius) + 20. A method in a Java program at the ranger's station at the edge of the forest receives this data as a stream. Every 10 pulses (i.e., once a second), the program computes the average temperature (as a double, in true Celsius) and sends it on a stream to a regional environmental station. The average temperature is also printed on a small local console, along with error notifications..
The method signature might look something like this:
public void tempRecordingLoop (InputStream iStream, OutputStream oStream);
1. InputStream and OutputStream are abstract. What actual types are needed inside the method? How do you get them?
2. Write the basic code.
3. When the sensor detects an error, it sends a 0 value (which is not otherwise a legal temperature). How should errors be handled?