Question: I need the Java code for the following: Write a program named SubstringTester which prompts the user to enter two strings and uses the indexOf

I need the Java code for the following:

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 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 comments, alignment, and camelHump for multi-word variables.. Submit only your .java file, do not submit a project, .class file, or program output.

Sample Output (user input is shown in red):

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!