Answer to Question #250393 in Java | JSP | JSF for Drunk

Question #250393

1. Write a program that generates a random number between 0 to 10. Use the following statements below for generating random number and the class Random from the package java.util:Random rand = new Random();int num = rand.nextInt(10);2. Display the generated random number with text: "The generated random number between 0 to 10 is: ".3. Name the class as RandomNumber and save the file.4. Compile and execute the program using the command prompt (cmd). If you do not have cmd, run it in JDoodle.

1
Expert's answer
2021-10-12T13:49:45-0400
import java.util.Random;

public class RandomNumber {
  public static void main(String[] args) {
    Random random = new Random();
    int number = random.nextInt(10);
    System.out.printf("The generated random number between 0 to 10 is: %d", number);
  }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS