Packagetest; Public classTest {voidPrintprimes (intN) { intCurprime; intNumprimes; BooleanIsPrime; int[] primes =New int[43]; primes[0]=2; Numprimes= 1; Curprime= 2; while(Numprimes <N) {curprime++ ; IsPrime=true; for(inti = 0; I <= numPrimes-1; i++){ if(Isdivisible (primes[i],curprime)) {IsPrime=false; Break ; } } if(IsPrime) {Primes[numprimes]=Curprime; Numprimes++ ; } } for(inti = 0; I <= numPrimes-1; i++) {System.out.println ("Prime:" +Primes[i]); } } BooleanIsdivisible (intIintcurprime) { if(curprime% i = = 0 ) return true; return false; }}
Packagetest;Import Staticorg.junit.assert.*;ImportOrg.junit.Before;Importorg.junit.Test; Public classTesttest {PrivateTest t=NULL; @Before Public voidSetUp ()throwsException {T=Newtest (); } @Test Public voidTest () {T.printprimes (0); T.printprimes (3); T.printprimes (5); }}
Master path overlay for software test HOMEWORK3