Designing an algorithm

Algorithm design option one - flow diagram

A flow diagram showing how a programme would calculate the braking distance for a new model of go-kart

Algorithm design option two - pseudo-code

wet_calc ← 1.5 OUTPUT “What speed is the go-kart travelling at?” speed ← USERINPUT WHILE (speed IS NOT integer) OR (speed < 10) OR(speed > 50) DO OUTPUT “Speed must be a whole number between 10 and 50. Try again.” speed ← USERINPUT ENDWHILE OUTPUT “Is the ground wet? (yes/no)” wet_ground ← USERINPUT IF wet_gound = “yes” THEN braking_dist ← (speed * 5)* wet_calc ELSE braking_dist ← speed * 5 ENDIF OUTPUT “The braking distance is: “ + braking_dist + “m”

Testing table

Tests will be required to test that the final program runs correctly.

Test noDescriptionTest dataTest typeExpected outcome
1Calculate normal speed on dry ground20, noNormal100m
2Calculate normal speed on wet ground20, yesNormal150m
3Borderline calculate normal speed on dry ground10, noBoundary50m
4Borderline calculate normal speed on wet ground10, noBoundary75m
5Test rejected input - below minimum5, yesErroneousAsked to input again
6Test rejected input - above maximum100, yesErroneousAsked to input again
7Test rejected input - not a numberten, yesErroneousAsked to input again

The problem has now been fully decomposed and an algorithm has been designed.