header

Homework 16

An automated device monitors air temperature and automatically records the high and low temperatures for the day in a disk file. Each record in the file consists of two space-delimited integer values: the low temperature for the day, and the high temperature for the day. Write a program to read such a file of data and display the number of days worth of data recorded in the file, the average low temperature, the average high temperature, the highest high temperature, and the lowest low temperature. The average temperatures are to be displayed to one decimal place and the highest high and lowest low are to be displayed as integer values. You may assume that the file never contains more than a year's worth of data.

Output Specifications

The output should be formatted as follows:

Days: ###

Average Low:  ###.#
Average High: ###.#

Minimum Low:  ###
Maximum High: ###

Where ### denotes an integer value in a field three characters wide and ###.# indicates a decimal value (to one decimal place) in a field five characters wide.

Input Specifications

The data is to be read from a file of unknown length in which each record consists of two space-delimited integer values. The first represents the low temperature for the day and the second represents the high temperature for the day. You may assume that there are no data errors in the file and that there is never more than a year's worth of data in the file.

Process Specifications

For the time period covered by the file data, determine the number of days, the average low temperature, the average high temperature, the minimum low temperature, and the maximum high temperature.

Miscellaneous Specifications

Use parallel arrays to store the daily lows and highs. Utilize three value-returning functions; one to return the average (as a double) of the values in an array of integers, one that returns the minimum value in an array of integers, and one that returns the maximum value in an array of integers. Use a void function to read the data from the file and another void function to display the results.

I've provided a main driver with stubs in Hmwk16.cpp. All you need to do is implement the functions. You will need to decide what formal parameters are needed in the functions and what actual parameters are needed in the invocations. Don't forget to specify how each parameter is used: in, out, or in/out.