Question: 1 . ( 6 0 points ) Use the method printPrimes ( ) for questions a - f below. ` ` ` private static void
points Use the method printPrimes for questions af below.
private static void printPrimes int n
int curPrime; Value currently considered for primeness
int numPrimes; Number of primes found so far.
boolean isPrime; Is curPrime prime?
int primes new int ; The list of prime numbers.
Initialize into the list of primes.
primes ;
numPrimes ;
curPrime ;
while numPrimes n
curPrime; next number to consider
isPrime true;
for int i ; i numPrimes; i
for each previous prime.
if isDivisible primesi curPrime
Found a divisor, curPrime is not prime.
isPrime false;
break; out of loop through primes.
if isPrime
save it
primesnumPrimes curPrime;
numPrimes;
End while
Print all the primes out.
for int i ; i numPrimes; i
System.out.println Prime: primesi;
end printPrimes
a points Draw the control flow graph for the printPrimes method.
b points Consider test cases mathrmtmathrmn and mathrmtmathrmn Although these tour the same prime paths in printPrimes they do not necessarily find the same faults. Design a simple fault that t would be more likely to discover than t would.
c points For printPrimes find a test case such that the corresponding test path visits the edge that connects the beginning of the while statement to the for statement without going through the body of the while loop.
d points List the test requirements for Node Coverage, Edge Coverage, and Prime Path Coverage.
e points List test paths that achieve Node Coverage but not Edge Coverage on the graph.
f points List test paths that achieve Edge Coverage but not Prime Path Coverage on the graph. Use the following program fragment for questions ae below.
w x;
if m
w; node
else
ww; node
node no executable statement
if y
x y; node
else
x y; node
z w x; node
a points Draw a control ow graph for this program fragment. Use the node numbers given above.
b points Which nodes have defs for variable w
c points Which nodes have uses for variable w
d points Are there any dupaths with respect to variable w from node to node If not, explain why not. If any exist, show one.
e points List all of the dupaths for variables w and x
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
