0

How can i solve this?

Write a java program to practice prime numbers between 0 and 99. ‱ The program randomly generates an integer number between 0 and 99 stored as intNum displays a question to ask the user “Is the number 
 a prime number ? ”. The user should respond “Yes” or “Not”. ‱ After the user types the answer, the program displays a message to indicate whether the answer is correct or not correct.

4th Nov 2022, 4:39 PM
Reem Taha
1 Answer
+ 4
To generate a random number, use the Random class. To ask for user input, use the Scanner class. To determine if a number is prime, you can implement an algorithm such as the Sieve of Eratosthenes https://en.m.wikipedia.org/wiki/Sieve_of_Eratosthenes Or you can also use the BigInteger class isProbablePrime method. https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/math/BigInteger.html Post your code attempt if you are stuck.
4th Nov 2022, 5:47 PM
Tibor Santa
Tibor Santa - avatar