Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program named SubstringTester which prompts the user to enter two strings and uses the indexOf method of the String class to report whether

Write a program named SubstringTester which prompts the user to enter two strings and uses the "indexOf" method of the String class to report whether the second string is a substring of the first string.

Enclose the strings in quotes as shown in the sample output below. Be sure that your program accepts strings with embedded spaces.

Section 4.4.9 in the text describes finding characters and substrings in a Java String and provides examples of using the indexOf method.

Note: You must use the "indexOf" method for your solution in order to receive credit for this assignment. Yes, there are other methods to extract and test for substrings, but for this assignment this is the method you need to use.

As always, follow the guidelines presented in the Programming Assignment rubric, including an ID header, descriptive comments, correct code alignment, and camelCase notation for multi-word variables.. Submit only your .java file, do not submit a project, .class file, or program output.

You may submit an unlimited number of times up to the due date, but only your last submission will be graded.

Expected Output (user input is shown in red). Make sure your program produces this output given the example user input. Feel free to test additional input values to thoroughly test your program.

Please enter a string: quick brown fox Please enter another string: brown fox "brown fox" is a substring of "quick brown fox"

Please enter a string: quick brown fox Please enter another string: red rabbit "red rabbit" is not a substring of "quick brown fox"

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

2nd Edition

0470624701, 978-0470624708

More Books

Students also viewed these Databases questions

Question

=+14.4. 1 Let C be the set of continuity points of F.

Answered: 1 week ago

Question

2. Are my sources up to date?

Answered: 1 week ago

Question

3. Is it a topic that your audience will find worthwhile?

Answered: 1 week ago

Question

2. Does the topic meet the criteria specified in the assignment?

Answered: 1 week ago