-
Notifications
You must be signed in to change notification settings - Fork 0
/
RollDice.java
39 lines (32 loc) · 1.1 KB
/
RollDice.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
import java.util.Random;
/**
This program simulates the rolling of dice.
*/
public class RollDice
{
public static void main(String[] args)
{
String again = "y"; // To control the loop
int die1; // To hold the value of die #1
int die2; // to hold the value of die #2
// Create a Scanner object to read keyboard input.
Scanner keyboard = new Scanner(System.in);
// Create a Random object to generate random numbers.
Random rand = new Random();
System.out.println(rand.nextInt());
System.out.println(rand.nextInt(5));
// // Simulate rolling the dice.
// while (again.equalsIgnoreCase("y"))
// {
// System.out.println("Rolling the dice...");
// die1 = rand.nextInt(6) + 1;
// die2 = rand.nextInt(6) + 1;
// System.out.println("Their values are:");
// System.out.println(die1 + " " + die2);
//
// System.out.print("Roll them again (y = yes)? ");
// again = keyboard.nextLine();
// }
}
}