Question
(Java Programing) You are to write a program to find all of the prime numbers between randomly chosen minimum and maximum values. You should write
(Java Programing)
You are to write a program to find all of the prime numbers between randomly chosen minimum and maximum values. You should write a class PrimesInInterval.
This class should have a method
public static boolean isPrime(int possiblePrime)
This method returns true if possiblePrime is a prime number, and false otherwise. This method does not have a println call.
This class should have a method
public static int floor()
that returns a randomly chosen positive int value less than 1000.
This class should have a method
public static int ceiling(int lowBound)
that returns a randomly chosen int value that is greater than lowBound (but note, to make sure our program finishes before the course is over, let's make the returned value random, but less than lowBound * 10).
This class should have a main method that
uses floor and ceiling to establish a range of numbers to check for being prime.
prints the floor and ceiling values.
loops through the potential prime numbers, using isPrime to determine whether each is a prime number.
prints the prime numbers
prints the number of prime numbers found
.
Hint: isPrime need only loop from 2 to (possiblePrime/2).
This program is based on Listing 6.7.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started