Question

**JAVA** Using Random rand = new Random(); Which of the following expression generates a random integer...

**JAVA**
Using Random rand = new Random();
Which of the following expression generates a random integer between 20 and 100, inclusive?

A. rand.nextInt() % 80 + 20
B. rand.nextInt() % 81
C. rand.nextInt() % 80
D. rand.nextInt() % 81 + 20

0 0
Add a comment Improve this question Transcribed image text
Answer #1

D. rand.nextInt() % 81 + 20

Add a comment
Know the answer?
Add Answer to:
**JAVA** Using Random rand = new Random(); Which of the following expression generates a random integer...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • IVOVI U UL Question 46 Suppose we have Random rand = new Random(); Which of the...

    IVOVI U UL Question 46 Suppose we have Random rand = new Random(); Which of the following expression generates a random integer between 20 and 100, inclusive? rand.nextint() 96 80 rand.nextint() 96 80 + 20 rand.nextInt() % 81 rand.nextInt() % 81 + 20 A Moving to another question will save this response. Moving to another question will save this response. Question 47 Suppose I have the following Scanner object: File file = new File("data txt") Scanner input = new Scanner(file);...

  • I would really like to find another way to do this program Random rand = new...

    I would really like to find another way to do this program Random rand = new Random(); String choice = null; boolean valid = false; int a = rand.nextInt(10); int b = rand.nextInt(10); int c = rand.nextInt(10); int d = rand.nextInt(10); while (!valid) { // do{ // if (a == b) { rand.nextInt(10); } if (a == c) { rand.nextInt(10); } if (a == d) { rand.nextInt(10); } if (b == c) { rand.nextInt(10); } if (b == d) {...

  • 1). The result of Java expression 5*7>3*(5+2) && 3*5-4<6 is ____ a. 35>35&&9<6 b. true &&...

    1). The result of Java expression 5*7>3*(5+2) && 3*5-4<6 is ____ a. 35>35&&9<6 b. true && false c. false d. False (2). You save text files containing Java language source code using the file extension___ a. .java b. .class c. .txt d. .src    (3). Which of the following is not a primitive data type in the Java programming language? a. boolean b. byte c. int d. Point (4). Given the Java statement int[][] vari = new int[5][7]; the value...

  • Java question Q1) Use the following code snippet which generates a random sized array with random...

    Java question Q1) Use the following code snippet which generates a random sized array with random contents to complete the following problems: public int [] createRandomArray() {         int size = (int) (Math.random() * 10) + 1;         int[] array = new int [size];         for (int i = 0; i < array.length; i++) {             array[i] = (int) (Math.random() * 10 ) + 1;         }         return array;     } Assignment...

  • Create a JAVA application which generates 20 random numbers between 1 and 100 and writes them...

    Create a JAVA application which generates 20 random numbers between 1 and 100 and writes them to a text file on separate lines. Then the program should read the numbers from the file, calculate the average of the numbers, and display this to the screen.

  • Question 1Which of the following statements is syntactically correct in C? A)  print("Winter is coming."); B)  printf("Winter "+"is"+”coming.”);...

    Question 1Which of the following statements is syntactically correct in C? A)  print("Winter is coming."); B)  printf("Winter "+"is"+”coming.”); C)  printf(Winter is coming.); D)  printf("Winter is coming."); E)  None of the Above Question 2 What is the percent code used in scanf for an character? A) %c B) %f C) %d D) %lf E) None of the Above Question 3 What is the value of the following arithmetic expression? 80 – 3 * 12 + 21 / 3  ​ A) 315 B)  37 C)  47 D) 24 E)  None of...

  • Write a Java program that does the following. a. Declare an integer 2D array with 5...

    Write a Java program that does the following. a. Declare an integer 2D array with 5 rows and 5 columns. b. Initialize the array's elements to random integers between 1 and 10 (inclusive). c. Display all the elements in the 2D array as a table of rows and columns. d. Display the row index and column index of all the even integers in the 2D array. e. Display the sum of first row's elements.

  • Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A....

    Question 21 Which of the following expression yields an integer between 0 and 100, inclusive? A. (int)(Math.random() * 100) B. (int)(Math.random() * 101) C. (int)(Math.random() * 100) + 1 D. (int)(Math.random() * 100 + 1 Question 23 The not equal comparison operator in Java is ________. A. != = B. <> C. ^= D. != Question 24 What is the output of the following fragment? for (int i = 0; i < 15; i++) { if (i % 4 ==...

  • C++ language Write a program that 1. generates a random integer between 100 and 1000, call...

    C++ language Write a program that 1. generates a random integer between 100 and 1000, call the number N 2. reads a file name from the keyboard 3. opens a file for output using the file name from step 2 4. generates N random numbers between 1 and 100 and writes them to the file from step 3 5. closes the file 6. opens the file from steps 3, and 4 for input 7. reads the numbers from the file...

  • A. Create a java program that generates 1000 random integers. Write the 1000 random integers to...

    A. Create a java program that generates 1000 random integers. Write the 1000 random integers to a file using the Formatter class. B. Create a second java program that opens the file with the 1000 integers using the Scanner class. Read in the integers and find and print out the largest, smallest and the average of all 1000 numbers. C. Repeat A from above but use the BufferedWriter class B. Repeat B from above but use the BufferedReader class.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
Active Questions
ADVERTISEMENT