Question: Beginner Java Programming (boolean, do/while loops, for loops, if/else loops) A prime number is a positive integer greater than 1 that is divisible only by

Beginner Java Programming (boolean, do/while loops, for loops, if/else loops)

A prime number is a positive integer greater than 1 that is divisible only by itself and 1. In this assignment, you are responsible for writing a complete Java program to display first N prime numbers. In other words, your program should list the first N prime numbers.

Functional Requirements

Your 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. Your program will display the first N prime numbers given by the user. For example, if the user enters 3, the program should display: 2, 3, 5 which are the first three prime numbers. If the user enters 6, the output would be: 2, 3, 5, 7, 11, 13.

Sample Run

Welcome to the list of N prime numbers program! =============================================== Please enter the value of N (positive integer): 6

First 6 prime numbers are: 2 3 5 7 11 13

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!