Question
using Java, strings and conditional statements and without using modules... Third: Suppose we consider a String of characters. Write a program that reads a target
using Java, strings and conditional statements and without using modules...
Third: Suppose we consider a String of characters. Write a program that reads a target first string from the keyboard and then another second String from the keyboard. It then tests whether the second string contains the target string. Your program should identify the first occurrence of the target first String. Your search should ignore case sensitivity. So the String "c At" within a sentence would be identified if the target String was "c at".
Your program must identify the starting and ending indexes of the target String within the second string. You code must also identify the characters preceding and following the target String, if there are any.
For example, if you are looking for the String "dog" in the String "Dogmatic concatenation is a small category", you should find the String "Dog" starting at index 0 with no character in front of it, and ending at index 2 with the character 'm' following it. (Note: You need only find the first occurrence of a given String in a sentence, even if more than one occurrence of a target string is contained in a sentence.)
So if we are looking for the string "c at" in the sentence Neither the public at large nor catatonic cats are llamas! "c at" would be found at index location 17 and ending at 20 with the characters 'i' in front and ' ' behind the string.
Example: Please enter a string of characters. 123 LOOK Please enter another string of characters. This is a test of the 3123 looking code.
The string "123 LOOK" was found at index 23 The character '3' precedes it. The character 'i' follows it.
Another example: Please enter a string of characters. The Please enter another string of characters. The test is not the only test.
The string "The" was found at index 0 Nothing precedes it. The character ' ' follows it.
One more example: Please enter a string of characters. The Please enter another string of characters. This test is just a test.
The string "The" was not found
Include your IPOs and Algorithms as comments in your .java file.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started