Monday, December 31, 2012

Programming for all, part 2: From concept to code

Programming for all, part 2: From concept to code:






Aurich Lawson




Do one thing, and do it well


In our first installment, we wrote several programs that really did nothing more than illustrate a concept. Let's turn the complexity up a notch and compose a program that actually solves a problem. The problem we are tasked with: given the high temperature of the past three days, compute the average and standard deviation.
To do this, we are going to need to implement an algorithm, the programming equivalent to a set of directions. It gives the major steps that one must take in order to solve a problem, but the details of how are left up to the programmer who implements the algorithm. For our problem at hand, we could write out our algorithm as follows:

  1. Read in three values

  2. Compute the sum of these values

  3. Compute the average by dividing the sum by 3.

  4. Figure out how far each value is from the average.

  5. Add the distances obtained in step four

  6. Take the square root of the value in step five

  7. Divide by the square root of 3


So, let us set out to implement our remedial algorithm in MHF:

Read 67 remaining paragraphs | Comments


DIGITAL JUICE

No comments:

Post a Comment

Thank's!