Question: JAVA programming Program that displays the prime numbers from the list of factors of a random generated even number in reverse order Example, 18, the
JAVA programming
Program that displays the prime numbers from the list of factors of a random generated even number in reverse order
Example, 18, the factors are 1,2,3,6 and 9. Therefore, prime numbers are 2,3. Program will then print 3, 2 in that order.
Step 1) FINISHED
//NumberInt method generates random number between range 50 100, returning even
public static int NumberInt(){
Random randNumber = new Random();
int randNumberInt = 50 + randNumber.nextInt((100 50)/2) * 2;
return randNumberInt;
}
Step 2)
//Write method Factors
//Method will be called in the main method and passed generated even
//Method will store factors of the even number in a queue and will return it
public static Queue
Queue
//Add your code
return factors;
}
Step 3)
//Write method FindPrimes
//Method will store the prime numbers from the list of factors and returns it
public static Stack
Stack
//Add your code
return primes;
}
Step 4)
//Write method printPrimes
//Method takes the stack of printPrimes as parameter
//Method displays all prime factors and doesnt return value
Step 5)
*Testing methods
public static void main(String...strings){
//NumberInt()
//Factors() method passing the returned value of NumberInt()
//FindPrimes() method passing the return queue of Factors()
//printPrimes() method passing the return stack of FindPrimes()
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
