POTD 10: Data flow graph coverage — LCM

Due 4-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

// Calculate_LCM takes two numbers and 
// return LCM (Lease Common Multiplier) of the two numbers
// Examples: 
//    LCM of 12 and 15 = 2 * 2 * 3 * 5 = 60
//    LCM of 12 and 18 = 2 * 2 * 3 * 3 = 36
//    LCM of 15 and 18 = 2 * 3 * 3 * 5 = 90

public static int Calculate_LCM(int n1, int n2)
{
    int result = 1;
    int i = 2;
    if (n1 > n2)
        result = n1;
    else 
        result = n2;
	
    int temp = result;
    while (result % n1 != 0 || result % n2 != 0)
    {
        result = temp * i;
        i++;
    }
      
    return result;
}
  1. Annotate the following Control Flow Graph for the Calculate_LCM method with defs and uses. Alternatively, you may draw a Control Flow Graph from scratch and then annotate the graph with all information (code on nodes, code on edges, defs, and uses).

    CFG for LCM method

  2. List all du-pairs, then derive du-paths (the du-paths then can be used as test requirements)
    Variables DU-pairs DU-paths
         
  3. Apply All-Defs coverage to design tests
    Variables Test requirements (DU-paths) Test paths Test cases (input values and expected output)
           
  4. Apply All-Uses coverage to design tests
    Variables Test requirements (DU-paths) Test paths Test cases (input values and expected output)
           
  5. Apply All-DU-Paths coverage to design tests
    Variables Test requirements (DU-paths) 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 4-June-2026 11:59pm EST, by 5-June-2026 11:59pm EST)
(-5 points) for 48 hours late (submitted after 5-June-2026 11:59pm EST, by 6-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-31 12:57