Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

a) Write a main( ) method that declares a String reference variable. b) Read a sentence (with spaces) using keyboard input. Create a String object

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

Database Principles Programming And Performance

Authors: Patrick O'Neil

1st Edition

1558603921, 978-1558603929

More Books

Students also viewed these Databases questions

Question

Minimum correct assembly requirements for sensitive pc

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

Discuss the Hawthorne experiments in detail

Answered: 1 week ago

Question

Explain the characteristics of a good system of control

Answered: 1 week ago

Question

State the importance of control

Answered: 1 week ago

Question

6. Does your speech have a clear and logical structure?

Answered: 1 week ago