Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. Write all of this code in main( ) in a test class in JAVA. a) Write a main( ) method that declares a String

. Write all of this code in main( ) in a test class in JAVA.

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) 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

c. Print the last letter of your sentence

d. Print whether your sentence contains the letter e

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 letter e 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

l. 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 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

Programming The Perl DBI Database Programming With Perl

Authors: Tim Bunce, Alligator Descartes

1st Edition

1565926994, 978-1565926998

More Books

Students also viewed these Databases questions