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

Question #250152

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.5. Correct syntax and logical errors if there are any.6. Once you have successfully compiled and execute the program, copy the source code and paste it here in the Submission box.

1
Expert's answer
2021-10-13T00:29:52-0400
import java.util.Random;
public class Main
{
	public static void main(String[] args) {
		Random rand;
        rand = new Random();
        int num = rand.nextInt(10);
        System.out.println("The generated random number between 0 to 10 is: "+num);
	}
}

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