Computer Science 30
4.0-Programming & Design
 

The Problem:

Add a column of numbers to determine the total and average of the numbers entered.

If you are thinking, " Been there, done that, got the tee-shirt!", be patient!

What are the assumptions?

  • Where are the numbers coming from? (keyboard, file on hard disk, digital output device, radio signal from out of space)
  • How many numbers are there? (0...999,999,999?)
  • What kind of numbers are they? (integers, real numbers, positive/negative?)
  • Are the numbers to be retrieved at some other point in time for reference?
  • Do the numbers represent specific units?
  • How should the output be formatted?
  • Are all the numbers significant? Could there be invalid numbers which shouldn't be included in our calculations?
  • To what accuracy (significant figures) should the average be calculated and shown?

The answers to these questions of course would become clear if you knew the meaning of the numbers. If you were a meteorologist and the numbers represented measurements of temperature taken from instruments at 60 minute intervals throughout the day, your answers to the questions become somewhat more clear. Typically, though, more information leads to more questions.

  • How are the numbers stored on the instrument?
  • How are they accessed?
  • Is the instrument reliable?
  • Could some temperature measurements be inaccurate or missing?
  • Is the instrument calibrated to degrees Celsius or fahrenheit?

    Can you think of more questions?

©Copyright Saskatoon Public Schools 2005 --- Page updated Friday, 2006-05-12 9:53 AM