CSC 271
Homework 3 in C++

Assigned Oct. 18, due Oct. 25

Write a program that reads in three double numbers, and prints (appropriately labeled) their sum and average, how many of them are positive, and how many of them are above the average. For example, if the input were
3.7 5.2 -4.7
the output might be
Sum: 4.2
Average: 1.4
2 of your 3 numbers are positive.
2 of your 3 numbers are greater than the average.

The summing and counting should be done by functions that take in the three numbers as parameters and return the answer. You may also want to write a read function and a printResults function to do all the I/O.

Also write a test function that calls sum, average, and countGreater on various well-chosen test cases, compares the answers with the right answers, and prints either a message for each failed test (showing the inputs, the right answer, and the actual answer), or "All tests passed".


Last modified: 
Stephen Bloch / sbloch@adelphi.edu