Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement the following methods in a class named StringPlay: // Write a method that returns true if s has leading or trailing whitespace, false otherwise

Implement the following methods in a class named StringPlay:

// Write a method that returns true if s has leading or trailing whitespace, false otherwise

public static boolean needsTrim(String s)

// Write a method that swaps the first three and last four characters of s

public static String swap3For4(String s)

// Write a method that has one String parameter, and returns true if the first half and last half of the parameter are the same ignoring case, and false otherwise.

public static boolean areHalvesEqual(String s)

Create a class named StringPlayTester which only contains main(). In main, the user should be prompted to enter a string (I'll call it str). main() will then call each method in StringPlay passing str as the formal parameter as summarized below:

boolean result1 = StringPlay.needsTrim(str);

String result2 = StringPlay.swap3For4(str);

boolean result3 = StringPlay.areHalvesEqual(str);

main() should output these 3 results with descriptive text. The user should then be prompted with "Run again (y/n)" and the program rerun if wanted.

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_2

Step: 3

blur-text-image_3

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

Modern Database Management

Authors: Jeff Hoffer, Ramesh Venkataraman, Heikki Topi

13th Edition Global Edition

1292263350, 978-1292263359

More Books

Students also viewed these Databases questions

Question

What are the advantages of using circular saws?

Answered: 1 week ago

Question

2. What role should job descriptions play in training at Apex?

Answered: 1 week ago