There's no compiling errors but for some reason I'm always directed to the "Invalid Choice" option after inputing my desired password length. Any advice on how to repair this glitch? Thanks.
import java.util.Scanner;
import java.util.Random;
public class Password
{
public static void main(String [] args)
{
Scanner in = new Scanner(System.in);
Random randNum = new Random();
String upperCase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
String lowerCase = "abcdefghijklmnopqrstuvwxyz";
String symbols = "!@#$%^&*()_+{}|<>?[]=-";
String numbers = "1234567890";
System.out.println("Password Generation Menu");
//Determine Character Sets
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] Lowercase, Uppercase, Numbers, and Punctuation");
System.out.println("[5] Quit");
//Determine Selection
System.out.print("Enter Selection (1-5): ");
String choice = in.next();
System.out.print(choice);
System.out.println();
// Detrermine Password Length
System.out.print("Password Length (1-14): ");
int length;
String passwordLength;
passwordLength = in.next();
length = Integer.parseInt(passwordLength);
System.out.print(length);
System.out.println();
//Determine Value Of Activity Level
String lowerLetter = "";
String upperLetter = "";
String symbol = "";
String number = "";
if (choice == "1"){
for (int counter = 0; counter < length; counter++) {
lowerLetter += lowerCase.charAt(randNum.nextInt(lowerCase.length()));
System.out.println("Password: " + lowerLetter);
}
}else if(choice == "2"){
for (int counter = 0; counter < length; counter++) {
lowerLetter += lowerCase.charAt(randNum.nextInt(lowerCase.length()));
upperLetter += upperCase.charAt(randNum.nextInt(upperCase.length()));
System.out.println("Password: " + lowerLetter + upperLetter);
}
}else if((choice == "3")){
for (int counter = 0; counter < length; counter++) {
lowerLetter += lowerCase.charAt(randNum.nextInt(lowerCase.length()));
upperLetter += upperCase.charAt(randNum.nextInt(upperCase.length()));
number += numbers.charAt(randNum.nextInt(numbers.length()));
System.out.println("Password: " + lowerLetter + upperLetter + number);
}
}else if((choice == "4")){
for (int counter = 0; counter < length; counter++) {
lowerLetter += lowerCase.charAt(randNum.nextInt(lowerCase.length()));
upperLetter += upperCase.charAt(randNum.nextInt(upperCase.length()));
number += numbers.charAt(randNum.nextInt(numbers.length()));
symbol += symbols.charAt(randNum.nextInt(symbols.length()));
System.out.println("Password: " + lowerLetter + upperLetter + number + symbols);
}
}else if((choice == "5")){
System.out.println("Done");
}else{
System.out.println("Invalid Choice");
}
}
}