所以我的在线 AP Comp Sci 老师没有回复我,我的程序遇到了问题。我需要根据此列表中的用户输入创建一个随机密码生成器:
System.out.println("※※※※※※※※※※※※※※※※※※※ | Password Generation Menu | ※※※※※※※※※※※※※※※※※※※");
System.out.println("※|==========================================================================|※");
System.out.println("※| [1] Lowercase Letters |※");
System.out.println("※| [2] Lowercase and Uppercase Letters |※");
System.out.println("※| [3] Lowercase, Uppercase and Numbers |※");
System.out.println("※| [4] Lowercase, Uppercase, Numbers and Symbols |※");
System.out.println("※| [5] Quit |※");
System.out.println("※|==========================================================================|※");
System.out.println("※※※※※※※※※※※※※※※※※※※※※※ | Your selection? | ※※※※※※※※※※※※※※※※※※※※※※※");
到目前为止,我遇到了问题
int selection = in.nextInt();
if (selection ==1)
{
System.out.println("How many characters will me used in the password? (1 - 14)");
int chars = in.nextInt();
while ( count <= chars)
{
int password;
password += rand.nextInt((122 - 97) + 1)+ 97;
count++;
}
System.out.println("Password: " + password);
}
else if (selection ==2)
{
System.out.println("How many characters will me used in the password? (1 - 14)");
int chars = in.nextInt();
while ( count <= chars)
{
while( !(randNum>=65 && randNum<=90)&& !(randNum>=97 && randNum<=122))
{
randNum = randNumList.nextInt();
int password;
password += randNum;
}
count++;
}
System.out.println("Password: " + password);
}
else if (selection ==3)
{
System.out.println("How many characters will me used in the password? (1 - 14)");
int chars = in.nextInt();
while ( count <= chars)
{
while( !(randNum>=65 && randNum<=90)&& !(randNum>=97 && randNum<=122)&& !(randNum>=48 && randNum<=57))
{
randNum = randNumList.nextInt();
int password;
password += randNum;
}
count++;
}
System.out.println("Password: " + password);
}
else if (selection ==4)
{
System.out.println("How many characters will me used in the password? (1 - 14)");
int chars = in.nextInt();
while ( count <= chars)
{
int password;
password += rand.nextInt((126 - 35) + 1)+ 35;
count++;
}
System.out.println("Password: " + password);
}
else if (selection ==5)
{}
else
{
System.out.println(" ERROR: " + selection + " is not on the menu ");
}
}
它说找不到变量密码,这是因为循环吗?当我在工作上落后时,我完全被难住和沮丧
(这是我第一次在这个网站上询问它的格式是否很奇怪)