Due Wednesday, 1999/10/06
Write a program which will prompt for a series of grades, reject any grades which are below 0.0 or above 100.0 (by printing an error message and prompting for them again), and print the average of the list of grades. You may use any appropriate combination of while, do/while, if/else, break, and continue to accomplish your objective. Make the control structure of the program as easy-to-understand as possible.
When run, your program should look something like this:
$ ./average Enter grades, one per line, or CTRL-D to end. 90.5 901.5 Must be between 0 and 100; try again. 91.5 92.5 ^D Count = 3 Average = 91.50 $
Reflect back on Project 1 and Project 2, and on the exercise problems that you found most difficult. Describe the process by which you convert a problem statement into a program. How do you know what variables are needed? How do you know which control structures (if, for, while, do, switch, etc.) to use? Do you write something on paper first? If so, what do you write? Do you start at the top of the program, or do you start with something in the middle and then fill in the details? Do you work "forward" from the inputs, or "backward" from the outputs? Do you start with a small program and then decorate it with additional functionality, or do you compose the full program before attempting to test it? Try to write an algorithm on "How To Program", based on your experience thus far in the course.
Reminder: your next journal is due Monday, 1999/10/11.
Copyright © 1999, Ray Ontko (rayo@ontko.com).