i need know how Write a program that tests whether a string is a valid password. The password rules are:
Write a program that prompts the user to enter a password and displays the password entered and whether it is valid or invalid.
If you have any problem with the code feel free to comment.
Program
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
Scanner sc = new
Scanner(System.in);
System.out.print("Enter the
password: ");
String pass = sc.nextLine();
System.out.println(pass+" is valid?
"+checkPassword(pass));
/*Test cases for code
verfication*/
// System.out.println("asdzx_12 is
valid? "+checkPassword("asdzx_12"));
// System.out.println("asdzxs_1a is
valid? "+checkPassword("asdzxs_1a"));
// System.out.println("johnw_7_ is
valid? "+checkPassword("johnw_7_"));
sc.close();
}
public static boolean checkPassword(String pass)
{
int digits=0, letters=0,
underscore=0;
char[] ch =
pass.toCharArray();
if(pass.length()<8)//return
falses if length is less than 8
return
false;
else {
for(int i=0;
i< ch.length; i++) {
//checking number of letters, digits and
underscore
if(Character.isDigit(ch[i]))
digits++;
if(Character.isLetter(ch[i]))
letters++;
if(ch[i] == '_')
underscore++;
}
//validating
password
if(letters>0
&& digits>=2 && underscore==1)
return true;
else
return false;
}
}
}
Output

i need know how Write a program that tests whether a string is a valid password....
8.4 in python
function that checks whether a string is a valid password. Suppose the pas rules are as follows: . A password must have at least eight characters - A password must consist of only letters and digits. ■ A password must contain at least two digits. Write a program that prompts the user to enter a password and displays valid password if the rules are followed or invalid password otherwise (Occurrences of a specified character) Write a function...
Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...
Write Java program: • Is at least 8 characters long • Contains at least 1 lower letter character • Contains at least 1 upper letter character • Contains at least 1 numeric digit • Contains at least 1 special character from the set: !@#$%^&* • Does not contain the word “and” or the word “the” Prompts the user for a password, including the requirements above in your output. Output a string that states valid or invalid. If invalid, state which...
CSC-295 Spring 2019 Assignment – String, StringBuilder and StringBuffer Write an application that prompts the user for a password that contains at least two uppercase letters, at least three lowercase letters, and at least one digit. Continuously reprompt the user until a valid password is entered. Display Valid password if the password is valid; if not, display the appropriate reason(s) the password is not valid as follows: The password did not have enough of the following: uppercase letters lowercase letters...
Part 1: Is this Crazy Password Valid? A good password (in this strange system) should have the following properties: Rule 1: The password should be between 4 and 25 characters inclusive, starting with a letter. Rule 2. The password should not be contained in a list (selected by the user) that contains passwords commonly used by many people thus making these passwords easy to guess. Comparisons with passwords from the list of common passwords should be case insensitive. For example,...
Write a program that asks the user to enter a password, and then checks it for a few different requirements before approving it as secure and repeating the final password to the user. The program must re-prompt the user until they provide a password that satisfies all of the conditions. It must also tell the user each of the conditions they failed, and how to fix it. If there is more than one thing wrong (e.g., no lowercase, and longer...
in C++, Design a program that asks the user to enter a password, and then analyze the password, and then analyze the password for the following weaknesses: 1. Fewer than 8 characters 2. Does not contain at least one uppercase letter and one lowercase latter 3. Does not contain at least one numeric digit 4. Does not contain at least one special character( a character that is not a letter or numeric digit) 5. Is a sequence of consecutive uppercase...
Design and implement a Java program (name it 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 lower-case letter, at least one upper-case 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...
Write a Java program that prompts the user to enter a password that matches a specific pattern. Your program must approve the user's entry.. Here is the pattern, in this order: 1 or more upper case letters two lower case letters 1 or 2 digits zero or 1 upper case letters any two of this group @#$%^&