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 15:40
Most networking media send data using in which data is represented by only two discrete states: 0s and 1s. a. digital signals b. contiguous signals c. ramp signals d. exponential signals
Answers: 1
question
Computers and Technology, 23.06.2019 15:00
Jake really works well with numbers and is skilled with computers but doesn't work well with others. which of the jobs discussed in this unit might be best for jake? why?
Answers: 3
question
Computers and Technology, 23.06.2019 18:30
The computers in the sales department did not have enough data storage capacity to contain all the information the department needed to store, and it was taking a long time for team members to access the data they needed. to fix the problem, the technician installed new, larger hard drives on all the computers.
Answers: 1
question
Computers and Technology, 24.06.2019 14:00
Fast answer i need for apex ! smartphones should be banned from the classroom in public schools so that students cannot cheat on test so easily? which is an example of a counter argument to the thesis above? a.the classroom is a place for learning not for making phone calls b. smartphones are useful learning tools in the modern classroom c.banning smartphones will not students pay attention to teachers any better d. banning smartphones would decreased incidents of theft
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
Mathematics, 31.12.2019 02:31