The following code consists of a single Java class, GeneratePassword. This class prompts the user for a desired password length and then generates a password based on the user's requested length. If the user asks for a length shorter than 8, the default length of 8 will be used. This code was written with the Java SE 1.7 JRE System Library:
/* * This is a simple password generation app */ import java.util.Scanner; public class GeneratePassword { public static void main(String[] args) { // passwordLength int set up to easily change the schema int passwordLength = 8; //default value Scanner in = new Scanner(System.in); System.out.println("How long would you like your password (min 8)?"); int desiredLength; ...