-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQuestion3.java
More file actions
36 lines (25 loc) · 791 Bytes
/
Copy pathQuestion3.java
File metadata and controls
36 lines (25 loc) · 791 Bytes
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
import java.io.*;
import java.util.Random;
class Dices
{
public static void main( String[] args )
{
Random ran = new Random();
int number = 0;
for (int x = 0; x <10; x++) {
number = ran.nextInt(6)+1;
//System.out.println(number);
}
try (PrintWriter file = new PrintWriter(
new BufferedWriter(
new FileWriter("test1.txt")));
) {
for (int i = 1; i <= 10; i++) {
file.println(number);
}
} catch (IOException e) {
e.printStackTrace();
}
System.out.println("File test1.txt has been created!");
}
}