-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrand.java
More file actions
32 lines (31 loc) · 801 Bytes
/
rand.java
File metadata and controls
32 lines (31 loc) · 801 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
import java.util.Random;
public class rand
{
public static void main (String args[])
{
Random r = new Random();
try
{
int number = Integer.parseInt(args[0]);
for(int i=0;i<number;i++)
{
System.out.print("Your random number is:");
System.out.println(r.nextInt(10));
}
}
catch (ArrayIndexOutOfBoundsException ex)
{
for(int i=0;i<r.nextInt(10);i++)
{
System.out.print("Your random number is:");
System.out.println(r.nextInt(10));
}
}
catch (NumberFormatException ex)
{
System.err.println("Error parsing your value.");
System.err.println(ex.getMessage());
System.exit(0);
}
}
}