Project #4
Acorn Survey     Due 21 March 2005

The students in FRST 317, Forest Resources, did a survey of oak trees in the nearby Roaring River Forest.  The land had been marked off into squares, each 100 yards on a side, and each square was assigned a 4-digit identification number.  The students in FRST 317 were randomly assigned a square and asked to do two things.  For each oak tree in their square, the assigned student was to measure the circumference of the tree and count the number of dead branches/limbs that could be seen on the tree.  Based on this information, the department arborist said that two characteristics of the Roaring River Forest can be estimated:  acorn production for a square (and for the forest overall) and health index for the square.  The arborist supplied the following formulas to help estimate these characteristics.

Acorn production for one tree =  ( 2.263 * circumference2 - 19.48 * deadbranches3 ) / 512

Naturally, the total acorn production for a square is the sum of the productions for all trees surveyed in the square.  The acorn production is measured in cubic feet.

Square health index = number-of-trees-in-square / number-of-dead-branches-in-square

Note:  These formulas are completely fictitious.  I made them up.  The real formulas to make such estimates are generally much more complex than what is above.
The higher the index, the better the health of the trees in the square.  Note that some squares have zero oak trees (they should be given an index of -1.0).  Also, some squares that have oak trees have no dead branches (they should be given an index of 99.0).  For all other situations, the index is calculated as shown above.

The data from the student's survey has been collected and put into a file named  oaks.dat  It is on the I:\ drive at   I:\jlwolfe\110\oaks.dat You should copy this file to the disk and folder where you are going to store the program.  Do not try to use the file while it is on the I:\ drive.  Each line of the file has the following form

firstname lastname     ID-number   number-of-trees  circumference  deadbranches  . . .

where the names are those of the student, the ID-number is for the square, the number of trees is how many oaks the student found.  This is followed by that many pairs of circumferences and dead branch counts.  The two names are each guaranteed to be one word.

Here is a small sample from the file:

Miss Peach        3222  4  14.8 0  26.2 0  19.6 0  68.5 3
Grimm Goose       5309  4  13.4 0  15.4 0  23.8 1  46.5 0
Snuffy Smith      5633  0
Cpl Figowitz      3098  2  33.0 1  46.5 1
Dagwood Bumstead  2097  8  43.0 0  23.0 0  42.8 0  12.0 0  29.9 1  12.0 0  52.6 2  84.8 6

This sample shows that Miss Peach surveyed square 3222 and found 4 oak trees; they were 14.8, 26.2, 19.6, and 68.5 inches in circumference, with 0, 0, 0, and 3 dead branches respectively.  You are to write a program that analyzes the data in oaks.dat and produces two reports.  One report is written to a file with the name acornsurvey.txt   This report has one line for each square; the lines have the form

firstname lastname             ID-number    #-trees     production     health-index

where "production" and "health-index" are for the entire square.  Here is a small sample of what the report should show

Miss Peach              3222   4    25.412   1.333
Grimm Goose             5309   4    13.864   4.000
Snuffy Smith            5633   0     0.000  -1.000
Cpl Figowitz            3098   2    14.294   1.000
Dagwood Bumstead        2097   8    59.284   0.889

This shows that Miss Peach's square can produce an estimated 25.412 cubic feet of acorns and has a health index of 1.333.  The second report is to be displayed on the screen.  It shows which square had the best production, which square has the worst health index (the lowest nonnative index), and what the total acorn production for the entire forest is.  The results should look something like this:

The most productive square is xxx with yyy cubic feet of acorns.

The square with the worst health is www with a rating of zzz

The total acorn production is ttt cubic feet of acorns.

Here, ttt, www, xxx, yyy, and zzz should all be replaced with the values that your program calculates.  Your program is required to have at least two functions in addition to main.  One function must be called OneSquare; its purpose is to read in and process the data for one square, updating the production and health information as necessary.  The other function must be called ShowResults; its purpose is to display the second report on the screen.

For extra credit,  include one other item in the second report.  Have it display the name of the student who found the most productive single oak tree in the entire forest and display what that tree's production was.
When you are finished with the program, print a copy of the .cpp file, print a copy of the acornsurvey.txt file, and print a copy of the report that appears on the screen and hand them all in.  Also, copy the .cpp file to the handin folder on the P:\ drive.  Be sure to name the .cpp file after yourself.