logo

Crowdly

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

✅ Перевірена відповідь на це питання доступна нижче. Наші рішення, перевірені спільнотою, допомагають краще зрозуміти матеріал.

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.

Більше питань подібних до цього

Хочете миттєвий доступ до всіх перевірених відповідей на moodle.ut.ee?

Отримайте необмежений доступ до відповідей на екзаменаційні питання - встановіть розширення Crowdly зараз!