Question: Modify Listing 5.15 to display all the prime numbers between 2 and 1,000, inclusive. Display eight prime numbers per line. Numbers are separated by exactly
Modify Listing 5.15 to display all the prime numbers between 2 and 1,000, inclusive. Display eight prime numbers per line. Numbers are separated by exactly one space.
Listing 5.15
![1 public class PrimeNumber { public static void main(String[] args) { final](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2022/11/636a7260ec464_480636a7260dc4ee.jpg)


1 public class PrimeNumber { public static void main(String[] args) { final int NUMBER_OF_PRIMES = 50; // Number of primes to display final int NUMBER_OF_PRIMES_PER_LINE = 10; // Display 10 per line int count = 0; // Count the number of prime numbers int number = 2; // A number to be tested for primeness 2 4. 5 8 System.out.println("The first 50 prime numbers are "); // Repeatedly find prime numbers while (count < NUMBER_OF_PRIMES) { // Assume the number is prime boolean isPrime = true; // Is the current number prime? 10 11 12 13 count prime numbers 14 15 // Test whether number is prime for (int divisor = 2; divisor
Step by Step Solution
3.40 Rating (156 Votes )
There are 3 Steps involved in it
Program plan Take as input numbers from 2 and 1000 Calcula... View full answer
Get step-by-step solutions from verified subject matter experts
