Below is your take-home final exam. By submitting this exam, you are pledging that you have done all of the work for this exam yourself, without any input or assistance from others. You also agree that if I have an inkling that you did not, in fact, do the work yourself, you will suffer the appropriate consequences.

Now that that's out of the way, the exam is divided into four sections. Each section contains what you must minimally accomplish to have a chance at earning the grade associated with that section. Accomplishing these tasks is not a guarantee that you will earn that grade. Your programs will also be graded on style (indenting, choice of variable and function names, etc.) and the program analysis you submit with each section.

You get one "Get Out of Jail Free" card where I will assist you when you're stuck. Make it count, because after the first one I start deducting points if you come back for more.

I will be available at the following times:

Without further ado.....

Section D

A Taylor series is an infinite sum that can be used to approximate a given function. For example, the mathematical function sine(x) generally is an irrational number, and thus can be difficult for a system such as a computer to compute. A Taylor series allows us to generate a reasonable approximation of such functions.

Your program is going to implement the Taylor series:

Taylor series for e^x

Since you obviously cannot do an infinite sum, your program should ask the user for two numbers - x, and another number representing the accuracy the user wants. This second number will determine how many terms from the Taylor series you will calculate. For example, if the user enters '2', you would calculate the first two terms of the equation, or 1 + x. If they enter '3', you would calculate the first three terms, etc.

Finally, the exp() function (see page 1017) will return the actual value of e^x. Compare your approximation to the result from this function.


The remaining sections all use the following input file.

I have a file that contains statistics for the class softball team. There are 10 players on the team, and the team will play 10 games. The information in the file is laid out on a per game basis as follows:

Game#  Firstname  Position  AtBats   Hits  StrikeOuts  Walks  HR

An example entry in the file would be:

1  Jeremy  SS   4    1   3   0   1

There may be more than one entry per person, and there will be more than one entry per game, but there will only be one entry per person, per game.

Batting average is simply calculated as the total number of Hits divided by the total at bats.

On Base Percentage is (Hits + Walks)/(AtBats + Walks)

Position will be a two letter code. There are 10 possible codes: CA, SP, RP, 1B, 2B, 3B, SS, LF, CF, RF

Section C

Your program should process the input file and output the following statistics:

  1. Total home runs for Jeremy
  2. Total strikeouts for all outfielders
  3. Batting average for all catchers
  4. On base percentage for all first basemen.
  5. Team batting average for game 6.

Section B

Using an array of structures, your program should process the input file and output the total hits, walks, strike outs, and home runs, as well as overall batting average and on-base-percentage for every player on the team.

Section A

Using as many classes as necessary, your program should be able to generate all the statistics required in Section B, as well those same statistics by position (the same person does not always play 1B). Instead of simply dumping all of those statistics to the screen, a method for allowing the user to choose which stat they want to see should be provided.