subject

SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.
This question involves the StringManip class, which is used to perform manipulation on strings.

The class provides the removeSpaces method, whose implementation is not shown. The method takes a string and returns a new string with spaces removed. For example, removeSpaces("hi how are you") returns "hihowareyou". The removeSpaces method will be used in part (b).

public class StringManip

{

/** Takes a string str and returns a new string

* with all spaces removed.

*/

public static String removeSpaces(String str)

{ /* implementation not shown */ }

/** Takes a string str and returns a new string

* with the characters reversed, as described in part (a).

*/

public static String reverseString(String str)

{ /* to be implemented in part (a) */ }

/** Determines whether str is a palindrome and prints a message

* indicating the result, as described in part (b).

* Precondition: str contains only lowercase letters and spaces.

*/

public static void palindromeChecker(String str)

{ /* to be implemented in part (b) */ }

}

(a) Write method reverseString, which takes a string str and returns a new string with the characters in str in reverse order. For example, reverseString("ABCDE") should return "EDCBA".

Complete the reverseString method below by assigning the reversed string to result.

/** Takes a string str and returns a new string

* with the characters reversed.

*/

public static String reverseString(String str)

{

String result = "";

return result;

}

For this question, let a palindrome be defined as a string that, when spaces are removed, reads the same forward and backward. For example, "race car" and "taco cat" are palindromes. You will write method palindromeChecker, which determines whether a string is a palindrome and prints a message indicating the result. Examples of the intended behavior of the method are shown in the following table.

Method CallPrinted Message
palindromeChecker("taco cat")taco cat is a palindrome
palindromeChecker("laid on no dial")laid on no dial is a palindrome
palindromeChecker("level up")level up is not a palindrome
(b) Write method palindromeChecker below. Assume that reverseString works as specified, regardless of what you wrote in part (a). You must use reverseString and removeSpaces appropriately to receive full credit. Your implementation must conform to the examples in the table.

/** Determines whether str is a palindrome and prints a message

* indicating the result, as described in part (b).

* Precondition: str contains only lowercase letters and spaces.

*/

public static void palindromeChecker(String str)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:00
Match the steps of the process to julia's analysis. 1. analyze choices. current costs for making phone calls to foreign countries averages between five and ten cents a minute. 2. determine the goals. julia needs to reduce the cost of telecommunications without reducing her employees' ability to do their jobs. 3. gather data. the corporate computer network will be able to handle the increased traffic that will occur as a result of voip. 4. evaluate the decision. julia will have her it department set up voip in the smallest domestic office. 5. make the decision. julia will have employees document the benefits and problems that result from using the new technology.
Answers: 1
question
Computers and Technology, 22.06.2019 00:00
Ahorse is how much percent more powerful than a pony
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
The blank button automatically displays next to the data when you select a range of numeric data which is an available option for creating a chart
Answers: 3
question
Computers and Technology, 23.06.2019 04:00
In a word processing program, such as microsoft word, which feature to you choose the desired picture enhancement?
Answers: 2
You know the right answer?
SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA. Assume that the class...
Questions
question
History, 22.07.2019 01:50
question
Mathematics, 22.07.2019 02:00
Questions on the website: 13722367