public class PrintPrimes { private static boolean isDivisible (int i, int j) { if (j%i == 0) return true; else return false; } 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 [100]; // The list of prime numbers. // Initialize 2 into the list of primes. primes [0] = 2; numPrimes = 1; curPrime = 2; while (numPrimes < n) { curPrime++; // next number to consider ... isPrime = true; for (int i = 0; i <= numPrimes-1; i++) { // for each previous prime. if (isDivisible (primes[i], curPrime)) { // Found a divisor, curPrime is not prime. isPrime = false; break; // out of loop through primes. } } if (isPrime) { // save it! primes[numPrimes] = curPrime; numPrimes++; } } // End while // Print all the primes out. for (int i = 0; i <= numPrimes-1; i++) { System.out.println ("Prime: " + primes[i]); } } // end printPrimes public static void main (String []argv) { // Driver method for printPrimes // Read an integer from standard input, call printPrimes() int integer = 0; if (argv.length != 1) { System.out.println ("Usage: java PrintPrimes v1 "); return; } try { integer = Integer.parseInt (argv[0]); } catch (NumberFormatException e) { System.out.println ("Entry must be a integer, using 1."); integer = 1; } printPrimes (integer); } }    Use the method printPrimes() for questions a–f below. (a) Draw the control flow graph for the printPrimes() method.(b) Consider test cases t1 = (n = 3) and t2 = (n = 5). Although thesetour the same prime paths in printPrimes(), they do notnecessarily find the same faults. Design a simple fault that t2would be more likely to discover than t1 would.(c) For printPrimes(), find a test case such that thecorresponding test path visits the edge that connects thebeginning of the while statement to the for statement withoutgoing through the body of the while loop.(d) List the test requirements for Node Coverage, Edge Coverage,and Prime Path Coverage.(e) List test paths that achieve Node Coverage but not EdgeCoverage on the graph.(f) List test paths that achieve Edge Coverage but not Prime PathCoverage on the graph

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

public class PrintPrimes { private static boolean isDivisible (int i, int j) { if (j%i == 0) return true; else return false; } 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 [100]; // The list of prime numbers. // Initialize 2 into the list of primes. primes [0] = 2; numPrimes = 1; curPrime = 2; while (numPrimes < n) { curPrime++; // next number to consider ... isPrime = true; for (int i = 0; i <= numPrimes-1; i++) { // for each previous prime. if (isDivisible (primes[i], curPrime)) { // Found a divisor, curPrime is not prime. isPrime = false; break; // out of loop through primes. } } if (isPrime) { // save it! primes[numPrimes] = curPrime; numPrimes++; } } // End while // Print all the primes out. for (int i = 0; i <= numPrimes-1; i++) { System.out.println ("Prime: " + primes[i]); } } // end printPrimes public static void main (String []argv) { // Driver method for printPrimes // Read an integer from standard input, call printPrimes() int integer = 0; if (argv.length != 1) { System.out.println ("Usage: java PrintPrimes v1 "); return; } try { integer = Integer.parseInt (argv[0]); } catch (NumberFormatException e) { System.out.println ("Entry must be a integer, using 1."); integer = 1; } printPrimes (integer); } }  


 Use the method printPrimes() for questions a–f below. 
(a) Draw the control flow graph for the printPrimes() method.
(b) Consider test cases t1 = (n = 3) and t2 = (n = 5). Although these
tour the same prime paths in printPrimes(), they do not
necessarily find the same faults. Design a simple fault that t2
would be more likely to discover than t1 would.
(c) 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) List the test requirements for Node Coverage, Edge Coverage,
and Prime Path Coverage.
(e) List test paths that achieve Node Coverage but not Edge
Coverage on the graph.
(f) List test paths that achieve Edge Coverage but not Prime Path
Coverage on the graph

AI-Generated Solution
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
steps

Unlock instant AI solutions

Tap the button
to generate a solution

Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education