-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGenerator.java
More file actions
24 lines (22 loc) · 829 Bytes
/
Copy pathGenerator.java
File metadata and controls
24 lines (22 loc) · 829 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
/* *****************************************************************************
* Name: Ada Lovelace
* Coursera User ID: 123456
* Last modified: October 16, 1842
**************************************************************************** */
public class Generator {
public static String randomString(int L, String alpha) {
char[] a = new char[L];
for (int i = 0; i < L; i++) {
int r = (int) ((Math.random() * alpha.length()));
a[i] = alpha.charAt(r);
}
return new String(a);
}
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
int L = Integer.parseInt(args[1]);
String alpha = args[2];
for (int i = 0; i < N; i++)
StdOut.println(randomString(L, alpha));
}
}