POTD 8: Graph for source — numberOccurrences

Due 2-June-2026, 11:59pm EST

Purpose: Purpose:

You may make a copy of a worksheet and complete this activity, or simply type your answers in any text editor.

You may work alone or with another student in this course.


Consider the following Java method

public static int numberOccurrences(char[] v, char c) 
{
   if (v == null) 
     throw new NullPointerException();

   int n = 0;
   for (int i=0; i<v.length; i++)
   { 
      if (v[i] == c) 
          n++;
   }
   return n;
}
  1. Draw a Control Flow Graph for the numberOccurrences method (You may draw the graph by hand, take a picture of your graph, and embed it in your write-up)
  2. Apply Node Coverage (NC) to design tests
    Test requirements Test paths Test cases (input values and expected output)
         
  3. Apply Edge Coverage (EC) to design tests
    Test requirements Test paths Test cases (input values and expected output)
         
  4. Apply Edge-Pair Coverage (EPC) to design tests
    Test requirements Test paths Test cases (input values and expected output)
         
  5. Derive prime paths
  6. Apply Prime Path Coverage (PPC) to design tests
    Test requirements Test paths Test cases (input values and expected output)
         

Grading rubric

[Total: 10 points]: Done (or provide evidence of your attempt, full or reasonable effort)

(-2.5 points) for 24 hours late (submitted after 2-June-2026 11:59pm EST, by 3-June-2026 11:59pm EST)
(-5 points) for 48 hours late (submitted after 3-June-2026 11:59pm EST, by 4-June-2026 11:59pm EST)


Submission

Making your submission available to instructor and course staff is your responsibility; if we cannot access or open your file, you will not get credit. Be sure to test access to your file before the due date.



Copyright © 2026 Upsorn Praphamontripong
Released under the Creative Commons License CC-BY-NC-SA 4.0 license.
Last updated 2026-05-30 22:58