Please help me with this program in Java: 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 @#$%^&
Here is the code for you:
import java.util.*;
class PasswordEvaluator
{
//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 @#$%^&
public static boolean isValid(String password)
{
String symbol = "@#$%^&";
boolean accepted = false;
//boolean hasLength = false;
int upperCaseCount = 0;
int lowerCaseCount = 0;
int digitCount = 0;
int symbolCount = 0;
for(int i = 0; i < password.length(); i++) //For each
character.
{
char c = password.charAt(i);
if(Character.isUpperCase(c)) //If
uppercase, increment counter.
upperCaseCount++;
if(Character.isLowerCase(c)) //If lowercase, increment
counter.
lowerCaseCount++;
if(Character.isDigit(c))
//If digit, increment counter.
digitCount++;
if(symbol.indexOf(c) != -1) //If has
symbol, mark flag.
symbolCount++;
}
{
if(upperCaseCount < 1)
{
System.out.println("Password should contain 1 or more uppercase
letter.");
return false;
}
if(symbolCount != 2)
{
System.out.println("Password should contain any two of special
characters from @, #, $, %, ^, &");
return false;
}
if(lowerCaseCount != 2)
{
System.out.println("Password should contain 2 lowercase
letter.");
return false;
}
if(digitCount != 2 && digitCount != 2)
{
System.out.println("Password should contain 1 or 2 digits.");
return false;
}
return true;
}
}
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
while(true) {
//System.out.print("Do you want detailed information on failure or
not...? ");
System.out.print("Choose (Y)es or (N)o...: ");
char c = (in.next()).charAt(0);
System.out.println("Enter your password.....");
System.out.println("Should contain one or more Uppercase letter,
two lowercase letter");
System.out.print("1 or 2 digits, any two of the following symbol @,
#, $, %, ^, & : ");
String password = in.next();
boolean flag = isValid(password);
if(flag)
System.out.println("The password is Acceptable.");
else
System.out.println("The password is not Acceptable. Its easy to
guess.");
System.out.println("Do you want to continue checking for another
password...? ");
System.out.print("Choose (Y)es or (N)o...: ");
c = (in.next()).charAt(0);
if(c != 'N' && c != 'n')
continue;
return;
}
}
}
And the output screenshot is:

Please help me with this program in Java: Write a Java program that prompts the user...
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 @#$%^&
NO LOOPS, write a program, in Java, that prompts the user for a hexadecimal string of EXACTLY 4 hex digits, no more, no less, converts the hexadecimal value to its decimal value using string, character parsing, and Math methods learned in this chapter, and then prints the original string and its converted decimal value. NOTE: Hex digits may be in UPPER or lower case.
Write a program that prompts the user for an integer that the player (maybe the user, maybe someone else) will try to guess. If the player's guess is higher than the target number, the program should display "too high" If the user's guess is lower than the target number, the program should display "too low" The program should use a loop that repeats until the user correctly guesses the number. Then the program should print how many guesses it took....
FOR JAVA: Summary: Write a program to assess password stringency. The solution should be named Password.java. Include these steps: Write an application that provides the criteria for a strong password, and accepts a user's password from an input dialog box. If the entered password is less than six characters, more than 10 characters, or does not contain at least one uppercase letter and one digit, prompt the user to enter again. When the user's entry meets all the password requirements,...
please use java Write a program that prompts the user to enter line of text (including whitespace). The program then replaces the following vocals with numbers: a = 1, e = 2, i = 3, o = 4, u = 5 and outputs the result to the console. The program does not consider case, so a = 1, A = 1, e = 2, E = 2, etc. Example: Input: Hello, how are you? Output: H2ll4, h4w 1r2 y45? The...
Write a program that separately prompts the user for a first name and last name and outputs a string containing the following information, in order: a. First letter of the user's name. b. First five letters of the user's last name. c. A random two-digit integer You must construct the desired string ensuring all characters are lowercase; output the identification string accordingly. Assume the last name contains at least 5 characters. You must use the Random (java.util.Random) class to generate...
i need know how Write a program that tests whether a string is a valid password. The password rules are: It must have at least eight characters. It must contain letters AND numbers It must contain at least two digits It must contain an underscore (_) Write a program that prompts the user to enter a password and displays the password entered and whether it is valid or invalid.
write a java program that displays the following:
Write a Java program that prompts the user to enter an integer and determines whether 1. it is divisible by 5 and 6, whether on 2. it is divisible by 5 or 6, 3. it is divisible by 5 or 6, but not both. Here is a sample run of this program: Sample run: Enter an integer: 10 Is 10 divisible by 5 and 6? false Is 10 divisible by 5 or...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
PLEASE complete this in java.
Write a program that prompts the user to enter a file name and displays the occurrences of each letter in the console window and in a file. Letters are case insensitive. Use “USAconst.txt” for input and “letterCount.txt” for output. Use try- catch blocks to handle checked exceptions. Here is a sample file output: is ወ The ወ ው The Enter file name: USAconst.txt The occurrence of A's is 2675 The occurrence of B's is 612...