Write a Java program that does the following:
- Generates 5 random numbers between 1 and 20 (each random number needs to be shown in the output).
- Sum the 5 random numbers and display the sum.
- Determines if the sum is a prime number.
The program should have this output (below is an example): The five random numbers are: , , , , and
The sum of the five random number is: The sum is / is not a prime number
I am really having trouble understanding how to write this. I figured out how to determine if a number is prime, but how do I generate the numbers and add them together?
Aucun commentaire:
Enregistrer un commentaire