Ask the user for a number of sides, and roll a dice-based on that number. Copy this line of code into your program: Random rand = new Random(1); Your program should prompt the user with the following. Write the prompt and get input. How many sides: Below is sample input to test your program. Do not put this into your code. This is an example input (other inputs may be tested): 6 Your program should output the following (given the example input). Do not hard-code this output. Result: 4 Don't forget to import java.util.Random; Code Skeleton: import java.util.Scanner; import java.util.Random; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); /* Type your code here. */ } }
Ask the user for a number of sides, and roll a dice-based on that number.
Copy this line of code into your program:
Random rand = new Random(1);
Your program should prompt the user with the following. Write the prompt and get input.
How many sides:
Below is sample input to test your program. Do not put this into your code. This is an example input (other inputs may be tested):
6
Your program should output the following (given the example input). Do not hard-code this output.
Result: 4
Don't forget to import java.util.Random;
Code Skeleton:
import java.util.Scanner;
import java.util.Random;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
/* Type your code here. */
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images