Question
1.Write a Java program in a source file called StringTools.java. In this program, you will write a number of Java methods that allow you control
1.Write a Java program in a source file called StringTools.java. In this program, you will write a number of Java methods that allow you control and test Java String objects. You may not use any Java StringBuffer or StringBuilder methods. You may use the Java String methods equals, compareTo, charAt, length, and indexOf. The methods include:a method called isDigit that takes a Java String type as its only parameter and returns a boolean value. The return is true if the String object contains only digit characters and false otherwise. Such a method is often called a predicate and in Java the convention is to begin such predicates with the word "is" in lower case followed by a capitalized word or words describing what the test. That is, the method name is in "camel case" as is the name isDigit.a method called isAlphanumeric that takes a Java String type as its only parameter and returns a boolean value. The return is true if the String object contains only digit and letter characters (upper or lower case) and false otherwise.a method called reverse that takes a Java String type as its only parameter adn returns a Java String type. The returned String is a new Java String that is the reverse of the parameter string. That is, given the String object "apple", reverse should return "elppa".a method called changeStr that takes a Java String type as its first parameters followed by a variable number of Java char parameters There must be an even number of char parameters; if not return null. The char parameters are considered as pairs. The method returns a new Java String object with all occurrences of the character first char of each pair replaced by the character second. char of the each pair Consider the following parameters "apple", 'p', 'd', 'a', 'z', 'e', 'a', 'b', 'a', 'd', 'e'. The char parameters are considered as the pairs 'p' and 'd'; 'a' and 'z'; 'e' and 'a'; 'b' and 'a'; and 'd' and 'e' for processing the changes. changeStr returns "zddla". Note that the pair 'b' and 'a' is not used as there are no 'b' characters in the String object "apple". Note that last pair 'd' and 'e' does not change the early substituion of 'd' for 'p' and the method applies the changes to the original String object only.
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