This assignment will be your first where you write a significant amount of code to solve some small problem. With what we have talked about so far, your ability to solve problems is still fairly limited, but it is growing. Last assignment you used just the I/O functions (and could do it with just the O part). This time we will add function calls and conditionals to help you solve a simple problem on a computer. I'm giving you three options to choose from depending on your particular preferences. You should choose one and make sure that the comments in the code you send to me make it very clear which one you have chosen. Even if you don't think you like math you should read the description of the problems just to see if they interest you. This idea of keeping an open mind should apply through the whole semester. For all the problems you should use basic recursion to get things to happen multiple times.
Standard Problem:
If you choose this option, you will write a program to calculate grade for a student taking this class. The one difference is that for now you don't have to drop the lowest grade. So your program should read in the 10 assignment grades, the 6 quiz grades, 2 test grades, and the class participation grade, in that order. It should print out the averages for each of those as well as the total average in the class given the formula on the syllabus. After you have their number average you should print the letter equivalent for it (just A, B, C, D, F will work, no +/- required). This is a problem where being able to redirect input will probably be very helpful. (For extra credit make it drop the lowest quiz grade and allow for multiple students to be processed in a row.)
Math Type:
One of the useful things that you learn in calculus is that functions can be approximated. Your calculus text will mention both the Maclaurin series approximation and the Taylor series approximation. They are basically the same other than Maclaurin series are always taken about x=0 and this is what we will be working with here. The definition of the Maclaurin series is f(x)~sum_i(x^i*(d/dx)^i(f(0))/i!). So this is the sum from i=0 up to some n (or infinity if you want to be really accurate). In the sum we have x raised to the i power (not an xor here) times the ith derivative of f(x) evalutated at 0 divided by i factorial. Obviously, this is a real pain to use on functions where taking the derivative isn't easy. However, for some functions where the derivatives are straightforward, performing this approximation is very easy. Examples of that would be e^x, sin(x), and cos(x). I want you to write a program that does a Maclaurin approximation of cos(x). That's not really that hard because the derivative is -sin(x), which has a derivative of -cos(x) which goes to sin(x) then back to cos(x). Also note that you are always evaluating at x=0 so all the terms for sin go to zero.
The first few terms in this series are:
1-0-x^2/2!+0+x^4/4!-0-x^6/6!+0+x^8/8!+...
For the assignment, I want you to ask the user for the x to use, as well as an accuracy. Use the math library function cos to get the real value of cosine at that value of x. Then iterate until the difference between the series value and what that function gives you is less than the input accuracy. In the loop, print out the value of the series once every hundred iterations. After the loop print out the real value, the value you got from the series, and how many terms you had to sum in it. (For extra credit, make your program use a Taylor series instead. This means inputing another value x0 which the series is expanded around.)
Utilizing the Stack:
This problem is smaller than the others in some ways, but it has an interesting twist to it. For this one you won't code so much, but you definitely have to think more. When given a set of numbers, there are many different things that you can calulate from them. The average (arithmetic mean), median, mode, and geometric mean are values you should all have heard about at some point in your math educations even if you don't remember exactly what they are. In the sciences, another value that is particularly important is the standard deviation (root mean square/RMS). This value is defined as the square root of the average of the squares of the deviations of the values. That's a few too many clauses stuck together. We could write it mathematically as this sqrt(sum((x_i-average)^2)/N), where x_i is the ith number in the sequence, average is the average of the numbers, and N is the number of numbers. I've used ^2 here for squaring, but of course you can't do it that way in C as ^ is bitwise xor.
Calculating this number takes two passes through the values. The first one has to find the average while the second finds the sum of the deviations. We haven't yet learned about a way to store off a variable number of values nicely yet (and even if you know about arrays you aren't allowed to use them for this). For this path I want you to write a program that calulates the RMS value given an input like the following: N x1 x2 x3 ... xn. The user will input how many numbers there are, then each number. They will not input them twice.