Question: In Java, write a complete Java program to display first N prime numbers. The program should list the first N prime numbers. Functional Requirements: The
In Java, write a complete Java program to display first N prime numbers. The program should list the first N prime numbers. Functional Requirements: The program should prompt the user for a positive number, or a value of -1 to terminate the program. If the user enters 0, or a negative number, the program will also end immediately. The program will display the first N prime numbers given by the user.
For example, if the user enters 2, the program should display: 2, 3 which are the first three prime numbers. If the user enters 4, the output would be: 2, 3, 5, 7.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
