Created
February 12, 2012 22:18
-
-
Save bholzer/1811143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
import java.util.Scanner; | |
public class Easy4 { | |
public static void main(String[] args) { | |
Scanner in = new Scanner(System.in); | |
System.out.println("How long would you like your password to be?"); | |
int length = in.nextInt(); | |
String list = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!?@#$&1234567890"; | |
StringBuilder password = new StringBuilder(length); | |
Random indexPicker = new Random(); | |
for (int i = 0; i < length; i++) { | |
password.append(list.charAt(indexPicker.nextInt(list.length()))); | |
} | |
System.out.println(password); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment