Question

public static boolean primeCheck (int num) int temp; boolean isPrime-true: for(int i-2;i<=num/ 2 ; i++) temp-numsi if (temp=-0) isPrime-false; break; return isPrime Given the above code segment, 1. (30 points) Draw a Control Flow Graph (CFG) for the code. 2. (10 points) Enumerate the Test Requirements for node coverage. Design a set of 3. 4. 5. test cases (input value num) that will satisfy node coverage. (10 points) Enumerate the Test Requirements for edge coverage. Design a set of test cases (input value num) that will satisfy edge coverage (20 points) Enumerate the Test Requirements for edge pair coverage. Design a set of test cases (input value num) that will satisfy edge pair coverage. (30 points) Enumerate the Test Requirements for prime path coverage. Design a set of test cases (input value num) that will satisfy prime path coverage.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

First of all lets number the code statements

public static boolean primeCheck(int num)

{

1 int temp;

2 boolean isPrime = true;

3,4,9 for (int i=2; i<=num/2 ; i++)

//for for loop 3 is for intializer statement

//int i=2; 4 for checking condition and at end 9 for i++

{

5 temp=num%i;

6 if(temp==0)

{

7 isPrime = false;

8 break;

}

}

10 return isPrime;

}

Code statements are numbered from 1-8 now lets create

control flow graph(CFG) of the code statement.

l (int temp. ( 3(int i-2 comparison statement of for loop 4 iftemp--0) is false comparison i<-num/2 is false if(temp=-0) is t

Add a comment
Know the answer?
Add Answer to:
public static boolean primeCheck (int num) int temp; boolean isPrime-true: for(int i-2;i<=num/ 2 ; i++) temp-numsi...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Code to be written in Java public static boolean isPrime(int n) Checks whether the parameter integer...

    Code to be written in Java public static boolean isPrime(int n) Checks whether the parameter integer n is a prime number. For this lab, it is sufficient to use the primality test algorithm that simply loops through all potential integer factors up to the square root of n and stops as soon as it finds one factor. (If an integer has any nontrivial factors, at least one of these factors has to be less than or equal to its square...

  • Consider the following function bubbleSort. int bubbleSort(int num[], int numel) {       int i, j, temp,...

    Consider the following function bubbleSort. int bubbleSort(int num[], int numel) {       int i, j, temp, moves = 0;       for (i = 0; i < (numel - 1); i++)       {             for (j = 1; j < numel; j++)             {                   //missing code             }       } } A. Complete the missing code:- (4 Points) B. Assume that the array sort[] which has 8 elements, initially contains the values:- 22 5 67 98 45 32 101 99...

  • I am given an input file, P1input.txt and I have to write code to find the...

    I am given an input file, P1input.txt and I have to write code to find the min and max, as well as prime and perfect numbers from the input file. P1input.txt contains a hundred integers. Why doesn't my code compile properly to show me all the numbers? It just stops and displays usage: C:\> java Project1 P1input.txt 1 30 import java.io.*; // BufferedReader import java.util.*; // Scanner to read from a text file public class Project1 {    public static...

  • C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished)...

    C programm , ´hello i need your help -Given the C program primes.c with the following main method: int main() { int num, res; char buffer[11]; bool finished = false; while (!finished) { printf("Enter n > 0 or quit\n"); scanf("%10s", buffer); if (strcmp(buffer, "quit") == 0) { finished = true; } else { // Convert input to number and compute n-th prime num = atoi(buffer); if (num > 0) { res = nth_prime(num); printf("Prime #%d is %d\n", num, res); }...

  • I am using python3.6 and i am getting an error on line 42 num = int(fin.readline())...

    I am using python3.6 and i am getting an error on line 42 num = int(fin.readline()) #reading first value valueError: invalid literal, for int() with base 10 Any help is appreciated, here is the code. reads from txt file a few integers in an array and sorts them. thank you! # Function to do insertion sort def insertionSort(arr):     # Traverse through 1 to len(arr)     for i in range(1, len(arr)):         key = arr[i]         # Move elements of...

  • Please help me ONLY for the second method : public static int[] runningGroups(String[] inputFileNames) throws IOException....

    Please help me ONLY for the second method : public static int[] runningGroups(String[] inputFileNames) throws IOException. The second method has an "array of files as a parameter". and return int [ ]. Each element of the return array is the number of group that can get from the first method.    I got an error Exception in thread "main" java.lang.NullPointerException Here my code: import java.io.*; import java.util.ArrayList; import java.util.Scanner; public class RunningGroups { public static void main(String[] args) throws IOException...

  • Recursion Exercises These exercises provide practice with recursion in Java. Objectives Module: To write recursive solutions...

    Recursion Exercises These exercises provide practice with recursion in Java. Objectives Module: To write recursive solutions for basic problems that require iteration. To identify and address base cases in a recursive method. Reminders during development Each of your solutions to the problems below should be in their own method. If a method header is provided for a problem, then your solution should have that exact method header. Any changes to the method header will receive a zero for that problem....

  • With a Scanner object created as follows, what method do you use to read an int...

    With a Scanner object created as follows, what method do you use to read an int value? Scanner input = new Scanner(System.in); A. input.int(); B. input.nextInt(); C. input.integer(); D. input.nextInteger(); What is the output of the following code? x = 0; if (x > 0) System.out.println("x is greater than 0"); else if (x < 0) System.out.println("x is less than 0"); else System.out.println("x equals 0"); A. x is greater than 0 B. x is less than 0 C. x equals 0...

  • Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr,...

    Our 1st new array operation/method is remove. Implement as follows: public static boolean remove( int[] arr, int count, int key ) { 1: find the index of the first occurance of key. By first occurance we mean lowest index that contains this value. hint: copy the indexOf() method from Lab#3 into the bottom of this project file and call it from inside this remove method. The you will have the index of the value to remove from the array 2:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT