The birdwatchers club of Cuyahoga County has decided to do their annual count of the not-so-rare Black Cap Carolina Chickadee. In order to do this they have broken up into different teams to fan out through the Wayne National Forest counting birds. Each individual is keeping a count, and this has been recorded into a file called "sightings.txt."

There are ten people per team and an indeterminate number of teams. In the data file all the numbers on the same line are from a single team.

The report is to be written to a file called "chickadeereport.txt."

Your program is to:

  • Open up the file for reading and open the other file for writing.
  • Find the total number of sightings for each team, numbering the teams as they read in. (Instead of ten variables it is better to use a loop that calculates the sum while reading into a single integer variable, and adds each additional variable to the sum.)
  • When the sum for one team has been computed output that sum to the output file which will be open simultaneously with the input file. Something like this: Total Chickadees sighted by Team 1 is 132
  • The program adds that sum to a master sum, resets the necessary sum variable and reads in the next group of scores.
  • We also have a prize for the team that sights the most birds. So keep a record of the max sighting as well as the Team number of the team who recorded that total.
  • At the end of your program you will print to your file
    • The total number of birds sighted.
    • The identity and total for the Team that won the prize.

Note: This involves a loop within a loop and two files which will stay open until the very near the end of the program. The inner loop will be a counter loop and the outer loop should be an eof loop, since there are different number of teams in different years.

sightings.txt:

17 11 22 4 17 4 6 6 10 8
17 17 1 3 1 11 19 14 3 12
15 12 14 9 4 22 21 20 14 23
23 6 11 18 21 16 11 19 19 6
23 3 2 21 9 8 21 7 5 4
11 20 22 21 21 19 11 21 1 10
4 11 14 18 0 10 16 14 16 16
14 21 2 9 10 14 6 21 9 20
21 23 12 10 12 8 22 8 11 4
0 15 2 19 17 10 14 18 9 5
9 11 7 18 0 18 9 2 17 18
5 17 20 16 6 21 17 21 9 0
10 18 17 12 11 23 15 22 23 4
14 22 21 4 22 22 3 23 7 9
1 23 9 15 17 5 1 14 5 12
14 10 2 22 21 8 12 23 18 23
10 23 0 17 20 3 19 9 2 14
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.