Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
A programmer builds a program that works out a pupil's average mark from five tests. During the testing stage, two problems appear.
Problem 1: a pupil who missed a test has only four marks, and the program cannot handle this. Nobody had said that a pupil might miss a test.
Problem 2: for the marks , , , and , the program outputs instead of . The design was right, but one line of the code adds the first mark twice and leaves out the last mark.
For each problem, say which stage the programmer should go back to, and why.
The program development life cycle has four stages. Analysis: identify the problem and the requirements, with abstraction and decomposition. Design: decomposition, structure diagrams, flowcharts and pseudocode. Coding: write the program code, with iterative testing. Testing: test the whole program with test data.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Problem 1. The requirement "a pupil may miss a test" was never found. So the programmer goes back to analysis, adds the requirement, and then changes the design and the code to match.
Problem 2. The design was right, but the code does not follow it. So the programmer goes back to coding and corrects the line. Check the fault: , and . That is the wrong output, so the line really does add the first mark twice. The right total is , and .
Answer: problem 1, back to analysis (a missing requirement); problem 2, back to coding (the code does not match the design). After each change the program is tested again.
What if? If the design itself had used the wrong formula, the programmer would go back to design first.
Log in to join the discussion.
Loading…