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

• Generate random numbers between 11 and 25 (inclusive) and print them until the

ID: 3856149 • Letter: #

Question

• Generate random numbers between 11 and 25 (inclusive) and print them until the number 13 is generated. At that point no more random numbers should be generated.

• Do not print 13. Instead print in a separate line all done

• Don’t print 20. If the number 20 is generated print two at signs @@ instead

• Use a single space (blank) to separate the numbers / at signs (see sample output)

• Print no more than 5 numbers in a single line. Every time 5 numbers have been printed start a new line. (if it takes 4 random numbers to get 13 only one line will be printed. If it takes 11 times to get 13 three lines will be printed etc.)

Notice: because the numbers are random your output might look different from mine

Sample Output

22 @@ 18 12 25

12 22 24 25 24

24 22 22 24

all done

Explanation / Answer

public class RandomInt { public static void main(String[] args) { int n1 = Integer.parseInt(args[0]); int n2 = Integer.parseInt(args[1]); double Random; if (n1 != n2) { if (n1 > n2) { Random = n2 + (Math.random() * (n1 - n2)); System.out.println("Your random number is: " + Random); } else { Random = n1 + (Math.random() * (n2 - n1)); System.out.println("Your random number is: " +Random); } } else { System.out.println("Please provide valid Range " +n1+ " " +n2+ " are equal numbers." ); } } }