Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program called PasswordTest that accepts a string from the user and

ID: 3758659 • Letter: W

Question

Write a java program called PasswordTest that accepts a string from the user and evaluates it as a password, giving it a valid or invalid verdict. A good password will be at least 8 characters and includes at least one lowercase letter, at least one uppercase letter, at least one digit, and at least one character that is neither a letter nor a digit. Your program will need to check each character in the string in order to render a verdict. For example, CS1301/01 is an invalid password because it has no lowercase characters. When the user enters the password, the program should display it's verdict of either "Valid" or "Invalid".

Design the program such that it asks the user if they want to continue with another password after each entry, ending the program only when they do not respond to the question with "yes".

For example:

Explanation / Answer

public static void main(String[] args)
{
String passwordIn;
boolean lengthCheck = false;
boolean upperCheck = false;
boolean lowerCheck = false;
boolean digitCheck = false;
boolean check = false;
passwordIn = JOptionPane.showInputDialog("Enter the password:");
for(int i=0;i<passwordIn.length();i++)
{
char s=passwordIn.charAt(i);
if(Character.isUpperCase(s))
{
upperCheck = true;
}
if(Character.isLowerCase(s))
{
lowerCheck=true;
}
if(Character.isDigit(s))
{
digitCheck = true;
}
if (passwordIn.length() >= 8)
{
lengthCheck = true;
}
}
if(upperCheck == true && lowerCheck == true && digitCheck == true && lengthCheck == true)
{
check=true;
}
if(check==true)
{
JOptionPane.showMessageDialog(null, "Welcome to chegg");
}
else
{
JOptionPane.showMessageDialog(null, "Invalid password!" + " " + "The"+ " password must contain 8characters or more," + " " + "have atleast 1" + " digit, 1 lower case letter," + " " + "and 1 upper case letter");
}
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote