Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1 : The user will be able to give a string as an argument to the method and the method will return the number

Task 1: The user will be able to give a string as an argument to the method and the method will return the number of characters in the string (including white spaces). Complete the method public static int returnTheLengthOfTheString to complete this task. See the method comments for more detail.
Task 2: The user will be able to give a string and an index position in the string as arguments to the method. The method will return the character located at that index position in the string (including white spaces). Complete the method public static char returnTheCharacterAtTheGivenIndex to complete this task. See the method comments for more detail.
Task 3: The user will be able to give a string and an index position in the string as arguments to the method. The method will return the substring starting at that index position in the string (including white spaces) to the end of the string. Complete the method public static String returnTheSubStringStartingAtTheGivenIndex to complete this task. See the method comments for more detail.
Task 4: The user will be able to give a string and two index positions in the string as arguments to the method. The method will return the substring starting at the first index position in the string and ending at the second index position in the string(including white spaces). Complete the method public static String returnTheSubStringBetweenStartAndEndIndex to complete this task. See the method comments for more detail.
Task 5: The user will be able to give a string as an argument to the method. If there are any occurrences of the substring "1999" in the supplied argument, then the method will return a new string with all occurrences of "1999" changed to "2022". Complete the method public static String changeAllOccurancesOf1999To2022 to complete this task. See the method comments for more detail.
Task 6: 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 7: 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 dpackage a2_strings_and_regex_Jtorres126;
public class StringRegExAssignment {
/*
* return the length of a given string
* return -1 is the string is null
*/
public static int returnTheLengthOfTheString(String word){
int numberOfCharacters =
return -1;
}
/*
*return the character at the given index in word
*/
public static char returnTheCharacterAtTheGivenIndex(String word, int index){
return '\0';
}
/*
* return the substring starting from the given index
*/
public static String returnTheSubStringStartingAtTheGivenIndex(String word, int index){
return "";
}
/*
* return the substring from the start index to the end index
*/
public static String returnTheSubStringBetweenStartAndEndIndex(String word, int startIndex, int endIndex){
return "";
}
/*
* if there are occurrences of 1999 in the paragraph, replace with 2022
*/
public static String changeAllOccurancesOf1999To2022(String paragraph){
return "";
}
/*
* 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 8 but no more than 12
*/
public static boolean checkIfPasswdIsValid(String passwd){
return false;
}
/*
* 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 0 to 9. Length at least 1, but no more than 32
*-- @ symbol
*-- Domain name - made up of uppercase and lowercase letters, digits 0 to 9. Length at least 1, but no more than 32
*-- Top-level domain - either .com or .net or .edu
*/
public static int countNumberOfValidEmailAddresses(String fileDump){
return -1(next is hte code the main method will be reading from) public class StringRegExDriver {
public static void main(String[] args){
System.out.println(StringRegExAssignment.returnTheLengthOfTheString("")); //0
System.out.println(StringRegExAssignment.returnTheLengthOfTheString("

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

At what level(s) was this OD intervention scoped?

Answered: 1 week ago