Homework #5

Due: December 2, 1998

1. [70 points] Having successfully written programs for E-Trade, you have now moved up to the Weather Channel (www.weather.com.) Here, you are in charge of a very simple weather simulator.

Here's how it works: You are to create the same program two times. The first time you create the program, you are to use array notation. The second time around, you are to use pointer notation. The whole point being that arrays and pointers are intimately connected and almost always interchangeable.

Here's what you need to do: You are to track the average daily temperature (in Fahrenheit) for 7 days in New York City. The daily temperatures are randomly generated to be within the range of 30-85 degrees. You must create a function called, initTemp that takes care of all this initialization, and you must also declare two #define constants, MINTEMP and MAXTEMP.

Once you have initialized the data, print it out in a simple table format. And, then print the average daily temperature for the entire week. To determine the average, you must create a function called, averageTemp that takes a single array and returns a floating point average value.

Next, create a function called, globalWarming that takes a single array and adds five degrees to each daily temperature. Pass your original temperature array to this function, and then print out the newly "warmed" data along with it average weekly temperature.

Here's some sample output:

Welcome to the Weather.com Global Warming Simulator.

Original Data:
------------------------------------
   46   50   67   75   81   52   80

        Average Temperature:  64.43

With Global Warming:
------------------------------------
   51   55   72   80   86   57   85

        Average Temperature:  69.43

2. [30 points] Do problem 6.9 (part a,g,k,l,m, and n) on page 247 in the text.

Note: Arrays in C always begin at 0. Therefore, when the book/problem refers to the first row, it is really referring to the row index value of 0. The second row refers to an index value of 1, and so on.