Student Name Student ID 26 gen is an object of Random Class that is Random gen=
ID: 3601090 • Letter: S
Question
Student Name Student ID 26 gen is an object of Random Class that is Random gen= new Random . If we want to use gen and its method nextint to generate intergers in the following ranges, which kind of sentences we should write. 0.-7 Answer 8-17 Answer: -10-10 Answer 3. Please write the output of the following program 3.1 Program1 public class Flower enum Rose fredrose, whiterose, yellowrose public static void main (Stringll args) Rose r; rRose.redrose System.out.printinr.ordinalO) System.out.printin() System.out.printintr name0) Answer:Explanation / Answer
ANS 2.3 :
1) 0------7:
import java.util.Random;
class GenerateRandomNumbers{
public static void main(String[] args) {
Random gen = new Random();
for(int i =0; i <5 ; i++)//place i<the random numbers you want in your output
{
int answer = gen.nextInt(8) + 0;//gen.nextInt((max - min) + 1) + min;
System.out.println(answer);
}
2) 8------17:
import java.util.Random;
class GenerateRandomNumbers{
public static void main(String[] args) {
Random gen = new Random();
for(int i =0; i <5 ; i++)//place i<the random numbers you want in your output
{
int answer = gen.nextInt(10) + 8; //gen.nextInt((max - min) + 1) + min;
System.out.println(answer);
}
3) -10-------10:
import java.util.Random;
class GenerateRandomNumbers{
public static void main(String[] args) {
Random gen = new Random();
for(int i =0; i <5 ; i++)//place i<the random numbers you want in your output
{
int answer = gen.nextInt(21) + -10; //gen.nextInt((max - min) + 1) + min;
System.out.println(answer);
}
*----------------------------------------------------------------------------------------------------------------------*
ANS 3.OUTPUT OF THE PROGRAM (3.1 PROGRAM 1)IS :
0
redrose
redrose