Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Create a class called Question1 this class should only have class methods . a) Please create a class method called tokenize , which returns

Please Create a class called Question1this class should only have class methods.

a) Please create a class method called tokenize, which returns a String and takes a String and character as input. Return a the String with the character inserted between character of the String. For example, if the String is "Simon" and the character '|' the method should return "S|i|m|o|n". If the character is a space, an unchecked exception with the message "The separator cannot be an empty space" should be thrown.

b)Please create a class method called merge, which returns a String and takes two Strings as input. The two Strings should be combined such that the shorter String is "inside" the larger String. For example, if the first String is "135" and the second "24" the method should return "12345". Similarly, if the first String is "79" and the second "680" the method should return "67890" because the second String is longer than the first. If the two Strings are the same length, the second is inserted into the first, e.g. "123" and "456" would be merged into "142536". The difference in length between the two Strings should not be more than 1. For example, "12345" and "123" should throw an error with the error message: "Strings should be near equal length"

c) Please create a class method called removeVowels, which returns a String and takes a String as input. The method should remove all vowels from the String and return it retaining the case of the input String. For example, "alphabet" should be returned as "lphbt", and "ALPHAbet" returned as "LPHbt

d) Please create a class method called substrings, which returns a String and takes a String and an int as input. The method should return all substrings of size n (where n is the int provided) separated by a comma. For example, "12345" with an int of 2 should return "12,23,34,45" with an int of 3 should return "123,234,345" etc. The int should not be more than half the length of the String, otherwise an unchecked Exception with the error message "n cannot be greater than length / 2" should be thrown.

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

Step: 3

blur-text-image

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

Java How To Program Late Objects Version

Authors: Paul Deitel, Deitel & Associates

8th Edition

0136123716, 9780136123712

More Books

Students also viewed these Databases questions