0

ユーザーに入力ダイアログからパスワードを入力するよう求めるアプリケーションを作成したいと考えています。パスワードは 10 文字未満で 6 文字以上である必要があります。また、パスワードには少なくとも 1 つの数字または文字が含まれている必要があります。パスワードがすべての要件を満たしている場合、ユーザーにもう一度パスワードを入力するように求め、2 番目のパスワードが最初のパスワードと一致するまで、ユーザーは続行できません。私のコードは次のとおりですが、文字または数字をチェックしていません。誰でも助けることができますか?

import javax.swing.*;
import java.awt.*;
import java.util.Scanner;

public class Password{

public static void main(String[] args){

String firstPassword="";
String secondPassword="";

char charChecked;

boolean letter = false;
boolean digit = false;

int len=firstPassword.length();

firstPassword= JOptionPane.showInputDialog("ENter");

if (( len<6 || len>10) || ! (Character.isLetterOrDigit(firstPassword.charAt(len))) )

{firstPassword= JOptionPane.showInputDialog("Enter the Correct Format of password");
}


if ((len>=6|| len<=10) || (Character.isLetterOrDigit(firstPassword.charAt(len))) )
do
{
secondPassword= JOptionPane.showInputDialog("Please enter again the password to confirm");
}
while (!(firstPassword.equals(secondPassword)));
if (firstPassword.equals(secondPassword))
{
JOptionPane.showMessageDialog(null,"Accepted");
}

}
}
4

1 に答える 1

0
int len=firstPassword.length();

firstPassword= JOptionPane.showInputDialog("ENter");

あなたのコードは反転しています...何かを入力した後に長さを呼び出す必要があります。

firstPassword= JOptionPane.showInputDialog("ENter");
int len=firstPassword.length();

何か言ってみて…

于 2013-10-11T16:19:57.570 に答える