Question: Write a test class to test the method isPrime in Listing 6.7 PrimeNumberMethod. java. Data from Listing 6.7 1 public class PrimeNumber Method { 2

Write a test class to test the method isPrime in Listing 6.7 PrimeNumberMethod. java.

Data from Listing 6.7

1 public class PrimeNumber Method { 2 pub11c static void main(String[] args)

{ System.out.printin("The first 50 prime numbers are in"): printPrimeNumbers (50): 3 4

1 public class PrimeNumber Method { 2 pub11c static void main(String[] args) { System.out.printin("The first 50 prime numbers are in"): printPrimeNumbers (50): 3 4 6 publ1c static void printPrimeNumbers (1nt numberofPrimes) { final int NUMBER_OF_PRIMES_PER_LINE = 10: II Display 10 per line 1nt count = 0; II Count the number of prime numbers 7 8 9 10 Int number = 2: II A number to be tested for primeness 11 II Repeatedly find prime numbers wh1le (count < numberofPrimes) { // Print the prime number and increase the count 1f (isPrime(number)) { count++; /7 Increase the count 12 13 14 15 16 17 1f (count % NUMBER_OF_PRIMES_PER_LINE = 0) { II Print the number and advance to the new line 18 19

Step by Step Solution

3.41 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

public class ABC Main Method public static void main String args int ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Document Format (2 attachments)

PDF file Icon

2038_60f58f350c081_871425.pdf

180 KBs PDF File

Word file Icon

2038_60f58f350c081_871425.docx

120 KBs Word File

Students Have Also Explored These Related Introduction to Java Programming and Data Structure Questions!