Exercise Test Driven

Please do NOT look ahead.
ONLY do what you are asked to do in each part.
The purpose is to give you the 'feel' of test driven development.

Ideally, you should be actually running code, but you would get most of the benefit if you just typed the algorithm.

Group work, part I
Write a program that will print all numbers from 1 to 100.
when done, look at part II

Group work, part II
Two is a number that will print.
Modify the program so that for an even number greater than 2, the number does not print.
(So, it prints 2, and the odd numbers)
when done, look at part III

Group work, part III
Three is a number that will print.
Modify the program so that for a number divisible by 3, that is greater than 3, it does not print.
(So, it prints 2,3, and numbers not divisible by 2 or 3)
when done, look at part IV

Group work, part IV
Given the lowest number, that has not been printed or eliminated,
that is a number that will print.
Modify the program so that given that number,
all numbers divisible by that number that are greater than that number, will not print.
Repeat until every number has been identified as a number that prints, or has been eliminated from printing.

Group work, part V
NOW run the program.
What numbers are printed?

The purpose is to give you the 'feel' of test driven development.

Individual work:
The goal is a program that prints out the square root of an input number.
In each phase, write the easiest or shortest program you can that fits the requirement.

Write a program that inputs 1, and prints out 1.
What does this program output for 4?

Write a program that works for previous data, and inputs 4, and prints out 2.
What does this program output for 9?
What other values might it have printed instead, if you truly were writing a program that worked only for 1 and 4?

Add the data values 9(3), 16(4),... until you feel comfortable that it will continue to work for new values.

Add the data value 2(1.41)    What did you have to change?

Now add data values 3(1.73), 5(2.23), 6(2.45).
How comfortable are you that it will work for 7,8,10,....?

Now add the data value 0.  Did it work? Why or why not?
If it did not work, fix it so that it does.

Now add the value (-1).
Did it work? Why or why not?

Now add the value 1.21.

At this point, how comfortable are you that your program will work for all possible real numbers?
What values would be best to test next?