Can somebody help tell what they think is the matter with this code. It is supposed to be a random password generator. You will see what is the matter with when it runs. Thanks in advance
/**
* This program generates random passwords based on the user selecting the character set and the length.
*
*
* @author John D. Barry
* @date January 26, 2009
*/
import java.util.Scanner;
import java.util.Random;
public class Password
{
public static void main(String [] args)
{
Scanner in = new Scanner(System.in);
System.out.println("************************************************************************ ");
System.out.println("* [1] Lowercase Letters * ");
System.out.println("* [2] Lowercase & Uppercase Letters * ");
System.out.println("* [3] Lowercase, Uppercase, and Numbers * ");
System.out.println("* [4] Quit * ");
System.out.println("************************************************************************ ");
System.out.println();
System.out.print("Enter your selection: ");
int selection = in.nextInt();
System.out.println();
if (selection == 1)
{
int randNum = 0;
Random randNumList = new Random();
while( randNum>=97 && randNum<=122)
randNum = randNumList.nextInt();
char firstChar = (char)randNum;
randNum = randNumList.nextInt();
char secondChar = (char)randNum;
randNum = randNumList.nextInt();
char thirdChar = (char)randNum;
randNum = randNumList.nextInt();
char fourthChar = (char)randNum;
randNum = randNumList.nextInt();
char fifthChar = (char)randNum;
randNum = randNumList.nextInt();
char sixthChar = (char)randNum;
randNum = randNumList.nextInt();
char seventhChar = (char)randNum;
randNum = randNumList.nextInt();
char eighthChar = (char)randNum;
randNum = randNumList.nextInt();
char ninthChar = (char)randNum;
randNum = randNumList.nextInt();
char tenthChar = (char)randNum;
randNum = randNumList.nextInt();
char eleventhChar = (char)randNum;
randNum = randNumList.nextInt();
char twelthChar = (char)randNum;
randNum = randNumList.nextInt();
char thirteenthChar = (char)randNum;
randNum = randNumList.nextInt();
char fourteenthChar = (char)randNum;
System.out.print("Enter the length of the password: ");
int length = in.nextInt();
if(length == 1)
{
System.out.println(firstChar);
}
else if(length == 2)
{
System.out.println(firstChar + secondChar);
}
else if(length == 3)
{
System.out.println(firstChar + secondChar + thirdChar);
}
else if(length == 4)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar);
}
else if(length == 5)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + fifthChar);
}
else if(length == 6)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar);
}
else if(length == 7)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar);
}
else if(length == 8)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar);
}
else if(length == 9)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar);
}
else if(length == 10)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar);
}
else if(length == 11)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar);
}
else if(length == 12)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar);
}
else if(length == 13)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar);
}
else if(length == 14)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar + fourteenthChar);
}
}
else if(selection == 2)
{
int randNum = 0;
Random randNumList = new Random();
while( (randNum>=65 && randNum<=90) && (randNum>=97 && randNum<=122))
randNum = randNumList.nextInt();
char firstChar = (char)randNum;
randNum = randNumList.nextInt();
char secondChar = (char)randNum;
randNum = randNumList.nextInt();
char thirdChar = (char)randNum;
randNum = randNumList.nextInt();
char fourthChar = (char)randNum;
randNum = randNumList.nextInt();
char fifthChar = (char)randNum;
randNum = randNumList.nextInt();
char sixthChar = (char)randNum;
randNum = randNumList.nextInt();
char seventhChar = (char)randNum;
randNum = randNumList.nextInt();
char eighthChar = (char)randNum;
randNum = randNumList.nextInt();
char ninthChar = (char)randNum;
randNum = randNumList.nextInt();
char tenthChar = (char)randNum;
randNum = randNumList.nextInt();
char eleventhChar = (char)randNum;
randNum = randNumList.nextInt();
char twelthChar = (char)randNum;
randNum = randNumList.nextInt();
char thirteenthChar = (char)randNum;
randNum = randNumList.nextInt();
char fourteenthChar = (char)randNum;
System.out.print("Enter the length of the password: ");
int length = in.nextInt();
if(length == 1)
{
System.out.println(firstChar);
}
else if(length == 2)
{
System.out.println(firstChar + secondChar);
}
else if(length == 3)
{
System.out.println(firstChar + secondChar + thirdChar);
}
else if(length == 4)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar);
}
else if(length == 5)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + fifthChar);
}
else if(length == 6)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar);
}
else if(length == 7)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar);
}
else if(length == 8)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar);
}
else if(length == 9)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar);
}
else if(length == 10)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar);
}
else if(length == 11)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar);
}
else if(length == 12)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar);
}
else if(length == 13)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar);
}
else if(length == 14)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar + fourteenthChar);
}
}
else if(selection == 3)
{
int randNum = 0;
Random randNumList = new Random();
while( (randNum>=65 && randNum<=90) && (randNum>=97 && randNum<=122) && randNum>=48 && randNum<=57)
randNum = randNumList.nextInt();
char firstChar = (char)randNum;
randNum = randNumList.nextInt();
char secondChar = (char)randNum;
randNum = randNumList.nextInt();
char thirdChar = (char)randNum;
randNum = randNumList.nextInt();
char fourthChar = (char)randNum;
randNum = randNumList.nextInt();
char fifthChar = (char)randNum;
randNum = randNumList.nextInt();
char sixthChar = (char)randNum;
randNum = randNumList.nextInt();
char seventhChar = (char)randNum;
randNum = randNumList.nextInt();
char eighthChar = (char)randNum;
randNum = randNumList.nextInt();
char ninthChar = (char)randNum;
randNum = randNumList.nextInt();
char tenthChar = (char)randNum;
randNum = randNumList.nextInt();
char eleventhChar = (char)randNum;
randNum = randNumList.nextInt();
char twelthChar = (char)randNum;
randNum = randNumList.nextInt();
char thirteenthChar = (char)randNum;
randNum = randNumList.nextInt();
char fourteenthChar = (char)randNum;
System.out.print("Enter the length of the password: ");
int length = in.nextInt();
if(length == 1)
{
System.out.println(firstChar);
}
else if(length == 2)
{
System.out.println(firstChar + secondChar);
}
else if(length == 3)
{
System.out.println(firstChar + secondChar + thirdChar);
}
else if(length == 4)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar);
}
else if(length == 5)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + fifthChar);
}
else if(length == 6)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar);
}
else if(length == 7)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar);
}
else if(length == 8)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar);
}
else if(length == 9)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar);
}
else if(length == 10)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar);
}
else if(length == 11)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar);
}
else if(length == 12)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar);
}
else if(length == 13)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar);
}
else if(length == 14)
{
System.out.println(firstChar + secondChar + thirdChar + fourthChar + sixthChar + seventhChar + eighthChar + ninthChar + tenthChar + eleventhChar + twelthChar + thirteenthChar + fourteenthChar);
}
}
else if(selection == 4)
{
System.out.println("Thanks for trying. Remember to create hard to guess passwords. ");
}
}
}