Question: Documentation on the String Class: Provides a method addTogether: Accepts two Strings as arguments The method should trim the leading and trailing whitespaces from each

Documentation on the String Class:

Provides a method addTogether: Accepts two Strings as arguments The method should trim the leading and trailing whitespaces from each String and add them together Returns the length of the trimmed, concatenated String Provides a method idProcessing A veterinary clinic needs to create unique identifiers for its animal clients. The identifier will consist of the owners first and last initials, the first initial of the animals name, and the pets year of birth (e.g. AHF2002) Write a method that will: Accept three Strings and an integer as arguments (first name, last name, pet name, year) Returns the desired identifier as a String Provides a method secretCode A famous pizzeria wants to encode its secret recipe. All ingredients are referred to using code words. Vowels (a, e, i, o, u) are replaced with a z and only the first three letters are used (e.g. tomato = tzmztz = tzm) Write a method that will: Accept a String as an argument Return the corresponding secret code String You may assume that all ingredients are at least three letters long

(PART 1) 1. Create a single public class JavaStrings which includes the three methods specified above. Your solution should use String methods. 2. You may include additional methods (e.g., main() or helper methods), but no methods beyond those specified need to be included, unless the requested methods depend on your new methods. 3. You may use additional methods included in the String class beyond those specified. (PART 2) 4. Add a private member variable SECRET_CODE_REGEX which is a Pattern object. 5. Create an associated static getter method getSecretCodeRegex. 6. Revise your solution so that the method secretCode uses SECRET_CODE_REGEX instead of String methods to perform the task. You should do the complete program, which consists of the requirements described in part 1 with the modifications described in part 2.

example main:

public class JavaStrings {

public static void main(String args[]) {

JavaStrings myObject = new JavaStrings();

// Print out examples from addTogether.

String oneExample = "12 4 6789";

String twoExample = "abcdef gh";

int theLength = myObject.addTogether(oneExample,twoExample);

System.out.println(theLength);

// Length is unchanged by adding whitespace to front and back

oneExample = " " + oneExample + " ";

twoExample = "\t" + twoExample;

theLength = myObject.addTogether(oneExample,twoExample);

System.out.println(theLength);

// Print out example of idProcessing

String personFirst = "Dorothy";

String personLast = "Gale";

String petName = "Toto";

int petBirth = 1899;

String theID = myObject.idProcessing(personFirst,personLast,

petName,petBirth);

System.out.println(theID);

// Print out examples from secretCode

String ingredientOne = "tomato";

String ingredientTwo = "WATER";

String theCode = myObject.secretCode(ingredientOne);

System.out.println(theCode);

theCode = myObject.secretCode(ingredientTwo);

System.out.println(theCode);

}

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!