Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java question! using thrwo and exception please! Write a program that identifies prime numbers that exist between minimum and maximum positive values provided by the

Java question! using thrwo and exception please!

Write a program that identifies prime numbers that exist between minimum and maximum positive values provided by the user.

If minimum value is greater than or equal to maximum value, the program should throw a InvalidRange exception and handle it to display a message to the user on the following format:

Invalid range: minimum is greater than or equal to maximum.

If any or both values are negative, the program should throw a NegativeValues exception and handle it by taking the absolute value of the negative values and finding the prime numbers between them as follows:

Negative Values: absolute values were used instead and the prime numbers are:

P1, P2,

Sample input/Output:

Sample run 1:

Enter minimum value:

10

Enter maximum value:

20

11 13 17 19

Sample run 2:

Enter minimum value:

20

Enter maximum value:

10

Invalid ramge: minimum is greaterthan or equal to maximum

Sample run 3:

Enter minimum value:

-10

Enter maximum value:

20

Negative Values: absolute values were used instead and the prime numbers are:

11 13 17 19

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_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions