# 1 program compute_insurance_premium() 2 integer driverAge, points 3 real baseRate, premium 4 Input(baseRate, driverAge, points) 5 safeDriveFactor = 0.0 6 premium = 0.0 7 switch (driverAge) { 8 case C1: 16 <= driverAge < 25 9 ageFactor = 3.0 10 if points < 2 then 11 safeDriverFactor = 40 12 end if 13 break; // End Case – C1 14 case C2: 25 <= driverAge < 45 15 ageFactor = 2.2 16 if points < 3 then 17 safeDriverFactor = 40 18 end if 19 break; // End Case – C2 20 case C3: 45 <= driverAge < 65 21 ageFactor = 1.5 22 if points < 5 then 23 safeDriverFactor = 80 24 end if 25 break; // End Case – C3 26 case C4: 65 <= driverAge < 100 27 ageFactor = 2.0 28 if points < 2 then 29 safeDriverFactor = 120 30 end if 31 break; // End Case – C4 32 default: 33 Output("Driver age out of range.") 34 } //End switch 35 premium = baseRate * ageFactor - safeDriverFactor 36 Output(premium) (i) Draw the program graph (ii) Compute the cyclomatic complexity (iii) Derive a set of basis paths that can be used to test the program

(i) Program Graph:

The program graph for the given code can be represented as follows:

1 -> 2, 3

2 -> 4

3 -> 4, 5, 6

4 -> 7

5 -> 7

6 -> 7

7 -> 8, 14, 20, 26, 32

8 -> 9

9 -> 10

10 -> 11

11 -> 12

12 -> 13

13 -> 35

14 -> 15

15 -> 16

16 -> 17

17 -> 18

18 -> 19

19 -> 35

20 -> 21

21 -> 22

22 -> 23

23 -> 24

24 -> 25

25 -> 35

26 -> 27

27 -> 28

28 -> 29

29 -> 30

30 -> 31

31 -> 35

32 -> 33

33 -> 34

34 -> 35

35 -> 36

(ii) Cyclomatic Complexity:

The cyclomatic complexity of a program can be calculated using the formula: V(G) = E – N + 2, where V(G) is the cyclomatic complexity, E is the number of edges, and N is the number of nodes.

In the given program graph, the number of nodes (N) is 31 and the number of edges (E) is 35. Thus, the cyclomatic complexity (V(G)) can be calculated as:

V(G) = 35 – 31 + 2

= 6

Therefore, the cyclomatic complexity of the program is 6.

(iii) Deriving Basis Paths:

Basis path testing involves selecting a set of test paths that ensure the execution of every statement and decision in the program at least once. To derive a set of basis paths for this program, we need to consider all possible paths through the graph.

Possible basis paths for the given program can be derived as follows:

1. 1-2-4-7-8-9-10-11-12-13-35-36

2. 1-2-4-7-8-9-10-11-12-35-36

3. 1-2-4-7-14-15-16-17-18-19-35-36

4. 1-2-4-7-14-15-16-17-18-35-36

5. 1-2-4-7-20-21-22-23-24-25-35-36

6. 1-2-4-7-20-21-22-23-24-35-36

7. 1-2-4-7-26-27-28-29-30-31-35-36

8. 1-2-4-7-26-27-28-29-30-35-36

9. 1-3-4-7-32-33-34-35-36

These basis paths cover all the possible paths through the program graph, ensuring that every statement and decision is executed at least once. By executing these basis paths as test cases, we can achieve good coverage of the program’s behavior.

### Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.

Click Here to Make an Order Click Here to Hire a Writer