CS 1500-1, Spring 2008

Solo Program 3

**OBJECTIVE:**

This assignment is designed to give you practice using*doubles*
in
mathematical functions and writing programs with user-defined
functions.

**THE ASSIGNMENT:**

Your assignment is to write a program that computes the average and standard deviation for four values input by the user.

To do this you will need to write three functions:

1. //explains program to user and directs them to enter appropriate values.

void printDirections();

2. //returns the arithmetic mean of the four arguments.

double average(double s1, double s2, double s3, double s4);

The average is the sum of the values divided by the number of values (four in this case).

It is also called the arithmetic mean.

3. //returns the standard deviation of the four arguments.

double stdDev(double s1, double s2, double s3, double s4);

To compute the standard deviation:

**INPUT AND OUTPUT:**

The program must prompt for four double values.

The program must compute the average and standard deviation of the values and report them to the user.

After the results are reported the program must ask the user if they would like to continue and either repeat or exit, depending on the user's choice.

Have a look at the sample script to see how it should look when you run the program.

**WHAT TO
TURN IN:**

Here is the list of things you have to turn in:

**DUE DATES:**

For the due dates, see the class schedule.

Solo Program 3

This assignment is designed to give you practice using

Your assignment is to write a program that computes the average and standard deviation for four values input by the user.

To do this you will need to write three functions:

1. //explains program to user and directs them to enter appropriate values.

void printDirections();

2. //returns the arithmetic mean of the four arguments.

double average(double s1, double s2, double s3, double s4);

The average is the sum of the values divided by the number of values (four in this case).

It is also called the arithmetic mean.

3. //returns the standard deviation of the four arguments.

double stdDev(double s1, double s2, double s3, double s4);

To compute the standard deviation:

- compute the average of the n values
- for each value compute the squared deviation (value - average)^2 (you are required to use the power function here)
- sum the squared deviations and divide by n-1 (three in our case) the degrees of freedom
- take the square root (you are required to use the square root function here)

The program must prompt for four double values.

The program must compute the average and standard deviation of the values and report them to the user.

After the results are reported the program must ask the user if they would like to continue and either repeat or exit, depending on the user's choice.

Have a look at the sample script to see how it should look when you run the program.

Here is the list of things you have to turn in:

- At the start of class on the
place the following item on the "counter" in front of me:**due date**

- a hardcopy (printed listing) of your program (the C++ source
code). Make sure all the code is properly formatted and that it all
shows on the paper.

- a hardcopy (printed listing) of your program (the C++ source
code). Make sure all the code is properly formatted and that it all
shows on the paper.
- Before midnight on the the
upload the following to the Homework Submission System:**due date**

- A copy of the source code (C++ code) (be sure your name is
in the comment section at the beginning of the program), named sprog3.cpp

- and a (filtered) script showing a test run of the program,
named sprog3.script

- A copy of the source code (C++ code) (be sure your name is
in the comment section at the beginning of the program), named sprog3.cpp

For the due dates, see the class schedule.