Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

type two statements that use nextint() to print 2 random integers betwe…

Question

type two statements that use nextint() to print 2 random integers between (and including) 100 and 149. end with a newline. ex: 112 102 note: for this activity, using one statement may yield different output (due to the interpreter calling randgen.nextint() in a different order). use two statements for this activity. see how to use zybooks for info on how our automated program grader works. 687316 5457930 qd3zy7 1 import java.util.scanner; 2 import java.util.random; 3 4 public class randomgeneratenumbers { 5 public static void main(string args) { 6 scanner scnr = new scanner(system.in); 7 random randgen = new random(); 8 int seedval; 9 10 seedval = scnr.nextint(); 11 randgen.setseed(seedval); 12 13 / your solution goes here / 14 15 }

Explanation:

Step1: Generate first random integer

System.out.println(randGen.nextInt(50) + 100);

The nextInt(50) generates a random integer from 0 (inclusive) to 50 (exclusive). Adding 100 shifts the range to 100 - 149.

Step2: Generate second random integer

System.out.println(randGen.nextInt(50) + 100);

Same logic as step 1, using nextInt(50) and adding 100 to get the desired range.

Answer:

System.out.println(randGen.nextInt(50) + 100);
System.out.println(randGen.nextInt(50) + 100);