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.
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.