-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpinGenerator.java
More file actions
61 lines (49 loc) · 2.01 KB
/
pinGenerator.java
File metadata and controls
61 lines (49 loc) · 2.01 KB
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import java.util.*;
public class pinGenerator {
public static void main(String[] args) {
Scanner choice = new Scanner(System.in);
Random r = new Random();
System.out.println("Pin Code Generator");
System.out.println("M: make a code, E: exit");
String Ans = choice.nextLine();
if (Ans.equalsIgnoreCase("M")) {
System.out.println("How long do you want the pin: ");
int pool = choice.nextInt();
choice.nextLine();
System.out.println("Want letter Y/N: ");
String letter = choice.nextLine();
System.out.println("Want numbers Y/N: ");
String numbers = choice.nextLine();
System.out.println("Want SpecialChar Y/N: ");
String specialChar = choice.nextLine();
if(pool <= 5) {
System.out.println("Not strong");
}
System.out.println("How many codes you want: ");
int opt = choice.nextInt();
choice.nextLine();
for(int i = 0; i < opt; i++ ) {
String code = ""; // reset code for each PIN
for (int j = 0; j < pool; j++) {
if (letter.equalsIgnoreCase("y")) {
char letters = (char) ('a' + r.nextInt(26));
code += letters;
}
if (numbers.equalsIgnoreCase("y")) {
int num = r.nextInt(10);
code += num;
}
if (specialChar.equalsIgnoreCase("y")) {
String specials = "!@#$%^&*";
char sp = specials.charAt(r.nextInt(specials.length()));
code += sp;
}
}
System.out.println("Generated PIN: " + code);
}
} else {
System.out.println("Bye...");
System.exit(0);
}
}
}