Copy these files to your local disk.
Use your text editor to modify the program Average.java so that it also finds the maximum of the numbers typed in. Note that you don't have to modify or compile the class Console.java; its method readInt is used by Average.java.
Hints:
Compile the java application as described on the previous page and run.
Write a Java application that reads in a set of floating point numbers, using Java type double, and computes the mean and standard deviation of these numbers.
You may fix the number of numbers, if you wish, or ask the user how many there are going to be.
In addition to the program Average.java, which computes the mean of a set of integers, you may wish to look at Volume.java to demonstrate the method readDouble.
As you read in numbers, you should store them into an array for later use in calculating the standard deviation.
For convenience sake, here is a text version of the equation for standard deviation. Assume that there are N numbers from x1 to xN and that the mean is written xbar.
stdev = sqrt( 1/N * (Sum from i=1 to N ((xbar - xi) ** 2)))
Hints:
Create a class to generate a sequence of random numbers using the linear congruential method (as discussed in Knuth vol.2). The sequence is started by a value called the seed. Given the current value of the sequence Xn, the next value Xn+1 = ((a * Xn) + c) mod m. This will generate a sequence of numbers between 0 and m, and given good choices of a, c, and m, the sequence should be pseudo-random. In Numerical Recipes in C, the following values are recommended:
Part 1: Change the rand method.
Hint: Use % for the mod operator.
Part 2: Change the instance variables and constructor so that you can also initialize the values of a, m, and c. Test different streams in the RNGtest.java program.