logo

Crowdly

For the method  evenSum  shown below, perform tasks a), b), and c). You can ass...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

For the method evenSum shown below, perform tasks a), b), and c). You can assume that nums has been well-defined (i.e., is not 'null' and, if not empty, has integers) when the method evenSum is called.

  1.   public static int evenSum(int[] nums) {

  2.     int esum = 0;

  3.     int i = 0;

  4.     while (i < nums.length) {

  5.        if(nums[i] % 2 == 0) {

  6.           esum += nums[i]; 

  7.        }

  8.        i++;

  9.     }

  10.     return esum;

  11.   } 

To Do:                                                                                                                                  

a) [1 mark] Write down the cyclomatic complexity. Show your calculation (i.e., the formula and the values used in the formula).

b) [1 mark] Write down a set of linearly independent paths. Use the code line numbers in the nodes of the CFG to express the paths.

c) [2 marks] Write down a minimal set of test cases needed to achieve 100% coverage of the set of linearly independent paths shown in part b). For each test case, state input, output, and the path that it covers.

More questions like this

Want instant access to all verified answers on moodle.ut.ee?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!