Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

in java 1) Choose the signature for methods that solve the following problems, o

ID: 3805963 • Letter: I

Question

in java

1) Choose the signature for methods that solve the following problems, or state that it is impossible to do so. You do not need to write these methods.

a- Generates a random integer between two given integers (inclusive).

b- Generates a random double between two given integers (exclusive).

c- Generates a random integer between two given integers (inclusive) that will be even or odd, depending on whether a given boolean is true (even) or false (odd).

d- Generates two random integers between two given integers.

e- Determines whether a given integer is or is not prime. Prime means that the number has no factors other than 1 and itself. Seven is prime. Eight is not prime because 2 and 4 are factors.

Explanation / Answer

First i would like to describe the generation of random numbers in java as

Random r = new Random();
int min = 10;
int max = 100;
int Result = r.nextInt(max-min) + min;

Now, as the question demands , the signature of methods can be as follows

A : private static int getRandomNumberInRange(int min, int max)

B : private static int getRandomNumberInRange(double min, double max)

C: private static int getRandomNumberInRange(int min, int max, bool flag)

D : private static int getRandomNumberInRange(int min, int max)

E : private static int IsPrimeOrNot(int number)