Using this snippet, the paths are as shown below. The numbers within square brackets are the node numbers. `
do{ [1]
System.out.print("Enter x:\t"); [2]
x = sc.nextInt();
if (x > 10){ [3]
System.out.println("x should be less than 10!!"); [4]
}
}while (x > 10); [5]
System.out.print("The number entered is " + x); [6]
`
Here is the control flow diagram. enter image description here
You can see that 1 → 2 → 3 → 4 → 5 → 6 is one idependent path. However, it is not feasible by looking at the codes. So does this path count as an independent path?
Aucun commentaire:
Enregistrer un commentaire