alright here are my instructions:
Display a menu giving the user a choice of character sets to use
to construct the password. (Note: Do not use the first range of
punctuation symbols with ASCII values from 33--47).
4. Allow the user to select the number of characters in the password (at least 1--14).
5. Create a randomly generated password from the selected character sets.
here is my code:
import java.util.Scanner;
import java.util.Random;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.File;
public class Password
{
public static void main(String [] args)
{
Scanner in;
in = new Scanner(System.in);
System.out.println(" Password Generation Menu ");
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] Lowercase, Uppercase, Numbers, and Punctuation *");
System.out.println("* [5] Quit *");
System.out.println("********************************************************");
System.out.println("Enter Selection (1-5): ");
int choice = in.nextInt();
System.out.println("Password Length (1-14): ");
int passwordLength = in.nextInt();
int randNum = ((int)(0+ Math.random()* 122));
String password = "";
randNum = ((int)(0+ Math.random()* 122));
boolean lowerCase = (randNum>=97) && (randNum<=122);
boolean upperCase = (randNum>=65) && (randNum<=90);
boolean numbers = (randNum>=48) && (randNum<=57);
boolean punctuation = (randNum>=58) && (randNum<=64);
System.out.println("\n");
for (int counter = 0; counter < passwordLength; counter++)
{
if (choice ==1)
{
while(lowerCase)
{
password += (char)randNum;
counter++;
}
System.out.println(password);
}
if (choice == 2)
{
while(lowerCase || upperCase)
{
password += (char)randNum;
counter++;
}
System.out.println(password);
}
if (choice ==3)
{
while(lowerCase || upperCase || numbers)
{
password += (char)randNum;
counter++;
}
System.out.println(password);
}
if (choice ==4)
{
while(lowerCase || upperCase || numbers || punctuation)
{
password += (char)randNum;
counter++;
}
System.out.println(password);
}
}
}
}
lol here is my output:
Password Generation Menu
********************************************************
* [1] Lowercase Letters *
* [2] Lowercase & Uppercase Letters *
* [3] Lowercase, Uppercase, and Numbers *
* [4] Lowercase, Uppercase, Numbers, and Punctuation *
* [5] Quit *
********************************************************
Enter Selection (1-5):
2
Password Length (1-14):
4
and my problem is that i kind of put together how i thought it work, so if i need to scrap this code, please tell me, but give me enough info so that i know how to repair. im not the best at java, but i dont see whats going wrong. thanks for help in advance.