Designing an algorithm
Algorithm design option one - flow diagram
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 no | Description | Test data | Test type | Expected outcome |
1 | Calculate normal speed on dry ground | 20, no | Normal | 100m |
2 | Calculate normal speed on wet ground | 20, yes | Normal | 150m |
3 | Borderline calculate normal speed on dry ground | 10, no | Boundary | 50m |
4 | Borderline calculate normal speed on wet ground | 10, yes | Boundary | 75m |
5 | Test rejected input - below minimum | 5, yes | Erroneous | Asked to input again |
6 | Test rejected input - above maximum | 100, yes | Erroneous | Asked to input again |
7 | Test rejected input - not a number | ten, yes | Erroneous | Asked to input again |
Test no | 1 |
---|---|
Description | Calculate normal speed on dry ground |
Test data | 20, no |
Test type | Normal |
Expected outcome | 100m |
Test no | 2 |
---|---|
Description | Calculate normal speed on wet ground |
Test data | 20, yes |
Test type | Normal |
Expected outcome | 150m |
Test no | 3 |
---|---|
Description | Borderline calculate normal speed on dry ground |
Test data | 10, no |
Test type | Boundary |
Expected outcome | 50m |
Test no | 4 |
---|---|
Description | Borderline calculate normal speed on wet ground |
Test data | 10, yes |
Test type | Boundary |
Expected outcome | 75m |
Test no | 5 |
---|---|
Description | Test rejected input - below minimum |
Test data | 5, yes |
Test type | Erroneous |
Expected outcome | Asked to input again |
Test no | 6 |
---|---|
Description | Test rejected input - above maximum |
Test data | 100, yes |
Test type | Erroneous |
Expected outcome | Asked to input again |
Test no | 7 |
---|---|
Description | Test rejected input - not a number |
Test data | ten, yes |
Test type | Erroneous |
Expected outcome | Asked to input again |
The problem has now been fully decomposed and an algorithm has been designed.