Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Java program with the following specifications: 1. The program should display a menu as follows: MENU [1] Prime or Composite [2] All Prime

Write a Java program with the following specifications:

1. The program should display a menu as follows:

MENU

[1] Prime or Composite

[2] All Prime Numbers

[3] Exit

Choose an option

2. Option 1 should ask for an integer from the user and displays a corresponding comment as Prime Number, Composite Number, or Neither Prime nor Composite.

3. Zero and 1 are neither prime nor composite, -1 is prime, while all other negative numbers are composite.

4. Option 2 should ask for an entry of two integers. It should determine and display all prime numbers between the two integers (including the two integers, if they are prime).

For example, if 3 and 11 are entered, the display should be:

3, 5, 7, 11

5. The program returns to the main menu after each display from the option and when an invalid input of the option is encountered.

6. Validate the option input. Only 1, 2 and 3 are acceptable, otherwise, display a message error and return to the main menu.

7. Exit option terminates the program.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_step_2

Step: 3

blur-text-image_step3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Genetic Databases

Authors: Martin J. Bishop

1st Edition

ISBN: 0121016250, 978-0121016258

More Books

Students also viewed these Databases questions