Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will write a program to perform some String operations. Read the input from the scanner Declare st1 and st2 as type String. Declare ch1

image text in transcribed

You will write a program to perform some String operations. Read the input from the scanner Declare st1 and st2 as type String. Declare ch1 and ch2 as char. Compare the strings and display, as appropriate o Which string is longer The 5 character of st1, or a message if the string has less than 5 characters Which word comes before in an alphanumeric comparison o Display if ch1 appears in st1 or not o The last position of ch2 in st2 (or - 1 if not in the string) Use printf for all of your output. Use appropriate format specifiers like %5, %d, %c, etc. Name your class program "String Operations" and submit your .java file in Canvas Sample output: Example 1: Enter two words and two characters: hello world a w Your words are: hello and world. And your characters are a and w. world is the same length as hello. The fifth character in hello is o. hello comes before world. a is not found in hello. The last position of w in world is index Example 2: Enter two words and two characters: hello Hello wy Your words are: hello and Hello. And your characters are w and y. Hello is the same length as hello. The fifth character in hello is o. Hello comes before hello. w is not found in hello. The last position of y in Hello is index -1 Example 3: Enter two words and two characters: java 823 w 2 Your words are: java and 823. And your characters are w and 2. java is longer than 823. java is less than five characters long. 823 comes before java. w is not found in java. The last position of 2 in 823 is index 1

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

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

Distinguish between force and impulse?

Answered: 1 week ago

Question

6. Use short-range goals to assist in achieving long-range goals.

Answered: 1 week ago

Question

10. What is meant by a feed rate?

Answered: 1 week ago

Question

explain what is meant by experiential learning

Answered: 1 week ago

Question

identify the main ways in which you learn

Answered: 1 week ago