Software Engineering HOMEWORK3

Source: Internet
Author: User

1 /******************************************************* 2 * Finds and prints n prime integers3 * Jeff Offutt, Spring 20034      ******************************************************/ 5      Public Static voidPrintprimes (intN)6     { 7         intCurprime;//Value currently considered for primeness8         intNumprimes;//Number of primes found so far.9Boolean isprime;//Is curprime prime?Ten         int[] primes =New int[Maxprimes];//The list of prime numbers. One          A         //Initialize 2 into the list of primes. -primes [0] =2;  -Numprimes =1;  theCurprime =2;  -          while(Numprimes <N) -         {  -curprime++;//next number to consider ... +IsPrime =true;  -              for(inti =0; I <= numprimes-1; i++)  +{//For each previous prime. A                 if(Isdivisible (primes[i], curprime)) at{//Found a divisor, curprime is not prime. -IsPrime =false;  -                      Break;//Out of loop through primes. -                 }  -             }  -             if(IsPrime) in{//Save It! -Primes[numprimes] =Curprime; tonumprimes++;  +             }  -}//End while the          *         //Print all the primes out. $          for(inti =0; I <= numprimes-1; i++) Panax Notoginseng         {  -System. out. println ("Prime:"+Primes[i]);  the         }  +}//End Printprimes

A. Drawing the control flow diagram of a function

B. Design a t2= (n=5) to discover but t1= (n=3) can not find the error

If the function's first line if (isdivisible (primes[i], curprime)) is mistakenly written as if (Isdivisible ( Primes[0], Curprime), which is thedetection of whether each subsequent number is a prime, only checks if it can be divisible by 2 . when n = 3 , the identified prime number is 2,3,5 and no error occurs, but when n = 5 , the prime number to be found is 2,3,5,7,9 Error occurred

C. Finding a set of test cases that do not pass through a while loop

n = 1

D. Find all the TR (test requirements) covered by the point overlay, Edge overlay, and master path

    1. Node coverage: [1,2,3,5,6,9,5,6,8,10,11,2,4,12,13,14]

Side overlay:[1,2,3,5,6,9,5,6,8,10,11,2,4,12,13,14]

[1,2,3,5,10,2,4,12,14]

Main path: [1,2,3,5,6,8,10,11]

[1,2,3,5,10,11]

[1,2,3,5,6,9]

[5,6,9,5]

[2,3,5,6,8,10,2]

[2,3,5,6,8,10,11,2]

[2,3,5,10,2]

[2,3,5,10,11,2]

[1,2,4,12,13,14]

[1,2,4,12,14]

[3,5,6,8,10,11,2,4,12,13,14]

[3,5,6,8,10,2,4,12,13,14]

[3,5,10,11,2,4,12,13,14]

[3,5,10,2,4,12,13,14]

[3,5,6,8,10,11,2,4,12,14]

[3,5,6,8,10,2,4,12,14]

[3,5,10,11,2,4,12,14]

[3,5,10,2,4,12,14]

[9,5,6,8,10,11,2,4,12,13,14]

[9,5,6,8,10,2,4,12,13,14]

[9,5,6,8,10,11,2,4,12,14]

[9,5,6,8,10,2,4,12,14]

Main path Overrides:

[0,1,2,3,5,6,8,10,11,2,4,12,13,14]

[0,1,2,3,5,6,8,10,11,2,4,12,14]

[0,1,2,3,5,6,8,10,2,4,12,13,14]

[0,1,2,3,5,6,8,10,2,4,12,14]

[0,1,2,3,5,6,9,5,6,8,10,11,2,4,12,13,14]

[0,1,2,3,5,6,9,5,6,8,10,2,4,12,13,14]

[0,1,2,3,5,6,9,5,6,8,10,11,2,4,12,14]

[0,1,2,3,5,6,9,5,6,8,10,2,4,12,14]

[0,1,2,3,5,10,11,2,4,12,13,14]

[0,1,2,3,5,10,2,4,12,13,14]

[0,1,2,3,5,10,11,2,4,12,14]

[0,1,2,3,5,10,2,4,12,14]

Software Engineering HOMEWORK3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.