wordCount. This method should accept a reference to a String object as an argument and return the number of words contained in the object.
arrayToString. This method accepts a char array as an argument and converts it to a String object. The method should return a reference to the String object.
mostFrequent. This method accepts a reference to a String object as an argument and returns the character that occurs the most frequently in the object.
frequency. This method accepts a reference to a String object as an argument and returns an integer array with the frequencies of all of the character occurrences. (e.g. if there are 6 a's (or A's) in the String, there is a 6 in the slot 0 of the array. If there are 2 z's, there is a 2 in the 26th slot (slot 25)).
replaceSubstring. This method accepts three references to String objects as arguments. Let's call them string1, string2, and string3. It searches string1 for all occurrences of string2. When it finds an occurrence of string2, it replaces it with string3. For example, suppose the three arguments have the following values:
string1: "the dog jumped over the fence" string2: "the" string3: "that"
With these three arguments, the method would return a reference to a String object with the value "that dog jumped over that fence."
Write a program that demonstrates all of the methods.
Part 2
Use the class as follows or write new classes as necessary. Select one (a, b, c, or d)
a. Write a program that encodes and decodes a block of text read in from a file. Encode by shifting letters by a constant value. Decode by shifting in the other direction. (So if the constant value is 4, then a is replaced by e, b is replaced by f, z is replaced by d, etc.) In your main method, encode and decode several cases to demonstrate the functionality of your program.
b. Write a program that translates an alphabetic phone number(such as 1-800-GO-FEDEX) to a fully numeric phone number (1-800-463-3339). And you will be doing the world a favor. In your main method, translate several phone numbers to demonstrate the functionality of your program.
c. Write a program to convert a String to Morse code. There is a table on page 651 of your book or you can Google it. Translate letters first. If you have time, add numbers and special characters. -..-! In your main method, translate several strings to Morse code to demonstrate the functionality of your program.
d. Write a program to guess the language of a String based on the frequency of characters. You can use the table of frequencies here: http://en.wikipedia.org/wiki/Letter_frequency. Distinguish among English, French, German, and Spanish. In your program, guess the language of several strings (at least one in each in the four languages) to demonstrate the functionality of your program. The program is not necessarily flawed if it incorrectly guesses a short string, but the algorithm should make sense.
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference
and should not be submitted as is. We are not held liable for any misuse of the solutions.
Please see the frequently asked questions page
for further questions and inquiries.
Kindly complete the form.
Please provide a valid email address and we will get back to you within 24 hours.
Payment is through PayPal, Buy me a Coffee
or Cryptocurrency.
We are a nonprofit organization however we need funds to keep this organization operating
and to be able to complete our research and development projects.