Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Task 6 : The user will be able to give a string as an argument to the method. The method will check if the given
Task : The user will be able to give a string as an argument to the method. The method will check if the given string matches the valid password regular expression. The method will return true if the pattern matches, false if any password rule is not met. Complete the method public static boolean checkIfPasswdIsValid to complete this task. See the method comments for more detail.
Task : The user will be able to give a string as an argument to the method. The method will match the regular expression pattern for a valid email address and count the number of those valid email addresses that are found in the file. The method will return the number of valid emails found in the string. Complete the method public static int countNumberOfValidEmailAddresses to complete this task. See the method comments for more detail Below is the code I already have
A valid password has the following pattern
starts with an uppercase letter
ends with a lowercase letter
the second to last character is either a number or
the length is at least but no more than
public static boolean checkIfPasswdIsValidString passwd
return true;
For the purposes of this assignment, assume a valid email address has the following pattern
four parts:
Recipient name made up of uppercase and lowercase letters, digits to Length at least but no more than
@ symbol
Domain name made up of uppercase and lowercase letters, digits to Length at least but no more than
Toplevel domain either com or net or edu
public static String countNumberOfValidEmailAddressesString fileDump
String emailPattern AZaz@AZazcomnetedu;
Matcher emailMatcher Pattern.compileemailPatternmatcherfileDump;
return emailMatcher.group;
Below are the strings being read in the driver System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWintera; true
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWinta; false less than minimum length
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWinterWonderlanda; false more than max length
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidwintera; false does not start with uppercase letter
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWinterA; false does not end with lowercase letter
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWintera; false the second to last letter is not a number or
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidWintera; true
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidMetered; true
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidSecondarys; true
System.out.printlnStringRegExAssignmentcheckIfPasswdIsValidBreadedx; true
System.out.printlnStringRegExAssignmentcountNumberOfValidEmailAddressesa@bcomjamaicawhatever jam@jammer.edu";
System.out.printlnStringRegExAssignmentcountNumberOfValidEmailAddressesa@b;
System.out.printlnStringRegExAssignmentcountNumberOfValidEmailAddressesnet";
System.out.printlnStringRegExAssignmentcountNumberOfValidEmailAddressesbb@anet";
System.out.printlnStringRegExAssignmentcountNumberOfValidEmailAddressesforeverand.ever@justdoit.net csciinstructor@georgiasouthern.edu, micromanager@igotnothingbettertodo.com";
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started