Representing algorithms

EasyMediumHard
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
Question 31
Medium

Table 1 shows three tests used to check the algorithm in Figure 1.

Complete the table to show what the values of the validBooking and excess variables would be for the given test data.

Figure 1

1  validBooking ← False
2  REPEAT
3      excess ← -1
4      OUTPUT 'Enter base target '
5      baseTarget ← USERINPUT
6      OUTPUT 'Enter actual sales '
7      actualSales ← USERINPUT
8      IF actualSales ≤ baseTarget THEN
9          OUTPUT 'Sales must be strictly greater than target'
10     ELSE
11         IF actualSales > 100 THEN
12             OUTPUT 'Sales cannot exceed maximum limit of 100'
13         ELSE
14             validBooking ← True
15         ENDIF
16     ENDIF
17 UNTIL validBooking = True
18 excess ← actualSales - baseTarget
19 OUTPUT excess

Table 1

Test typeTest dataValuevalidBookingexcess
NormalbaseTarget50
actualSales85
ErroneousbaseTarget60
actualSales45
BoundarybaseTarget40
actualSales100
[4]

Representing algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Representing algorithms