int a = 7; int b = 0; while (a = 1; b -= 5) {System.out.print (b + \" \");} Syst
ID: 3840101 • Letter: I
Question
int a = 7; int b = 0; while (a = 1; b -= 5) {System.out.print (b + " ");} System.out.println (); a + = 4;} System.out.println ("a=" + a + " b=" + b); Write the code to instantiate a new Random object and bind it to a variable of the correct type. Using this object, answer the next 3 questions: Write the code to generate a random number in the interval [0, 6] Write the code to generate a random number in the set {0, 2, 4, 6, 8, 10, 12} Write the code to generate a random number in the set {1, 3, 5, 7} When writing Practice-It solutions, are you writing client or supplier code? Explain your answer. What is meant by the state of an object?Explanation / Answer
7 2
11 6 1
15 10 5
a = 19 b = 0
1. Random r = new Random();
2) int val = r.nextInt(7); //This will generate random number from 0 to 6 incusive
3) int val = ( r.nextInt(13) / 2 ) * 2
3) int val = ( r.nextInt(4) ) //this will generate numbers from 0-3
val = 2*val + 1 //1 , 3,5 ,7
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.