I uploaded the lab using pics.
Just do steps 2 and 3
p.s
Sentence doesn’t have to be long.
Step 2. Write all of this code in main( ) in a test class.
a) Write a main() method that declares a String reference variable.
b) Read a sentence (with spaces) using keyboard input. Create a String object using this input. Input a
sentence that is long enough and has enough letters to accomplish each of the following tasks.
C.
e.
c) Write the String method calls and print the output for each of these tasks. Note that some of these cannot
be written with one line of code and one String class method call.
a. Print the number of characters your sentence contains.
b. Print the first letter of your sentence.
Print the last letter of your sentence.
d. Print whether your sentence contains the letter ‘e’.
Print whether your sentence contains “ay” or not.
f. Print the number of times the letter ‘e’ appears in your sentence.
g. Find the position of the last occurrence of the letter e’ in your sentence.
h. Find the position of the second occurrence of the lettere in your sentence. .
i. Print how many characters your sentence contains besides the space character.
j. Add the words “you know” to the sentence.
k. Print a completely upper case version of your sentence.
1. Extract and print a substring of five characters from your sentence.
m. Print a String where all the chars ‘a’ are replaced with the char ‘x’.
Step 3:
Create a project to perform manipulations on a string of characters.
Write a program that will allow the user to change every occurrence of the space character with the string,
“”.
Create two classes.
Replacer class, which has at least two fields, the original string, stored in a String object and the converted
string, stored in a StringBuilder object.
The constructor method should take a String as an argument and assign it to both fields.
You need a replace() method that will take in two arguments: the character to be replaced and the sequence of
characters to replace it with. This method will use StringBuilder methods and logic to change all occurrences
of the char in the original string to a new string, while still preserving a copy of the original string. (Note: The
more general form of this method will replace all occurrences of a String with another String.)
Write a get() method to get the original string. Write a get() method to get the converted (StringBuffer)
string. Write a set() method to change the original string to a new string (updating the StringBuilder too).
Driver class:
Write a class with the main() method that tests your Replacer class. The user can enter strings, and convert
each to another string using the replace() method that you wrote. Use the get() methods to print results to the
screen. Allow the user to enter a brand new string until they decide they are done.
Step 4: The debugger tutorial
In the BlueJ menu bar, open the “Help” menu. From this menu choose “BlueJ Tutorial”.
Read chapter 7 entirely and use the provided code to walk through the example.