Alter your program such that it will identify a target String within another String. Prompt the user for a String. Then prompt the user for a target String. Your program should find each occurrence of that target string in the other String. If the target string is not contained in the other string indicate that to the user. For each occurrence of the target string contained in the other String, display the starting index of the target string, the ending index of the target string, the ASCII character preceding the target string, the ASCII character following the target string. You must find strings that differ only in case. Place this code inside a do-while loop and allow the user to repeat it as many times as they would like.
- Alter your
program such that it will identify a target String within another String. Prompt the user for a String. Then prompt the user for a target String. Your program should find each occurrence of that target string in the other String. If the target string is not contained in the other string indicate that to the user. For each occurrence of the target string contained in the other String, display the starting index of the target string, the ending index of the target string, the ASCII character preceding the target string, the ASCII character following the target string. You must find strings that differ only in case. - Place this code inside a do-while loop and allow the user to repeat it as many times as they would like.
- submit your program as an Eclipse .zip project
Example of what the program might look like running.
This program identifies if a target String is contained within anoteher String.
And, if it is there it returns the first occurence of that String.
It also identifies the character before the found String and the character after the found String.
Please enter a target String:is
Please enter the String to be searched:This iss a test of the issue of finding is
The target "is" is found at index 2 in "This iss a test of the issue of finding is"
The character "h" is in front of it'
The character " " is following it.
We will now check for multiple instances of the target
The target "is" is found at index 2 in "This iss a test of the issue of finding is"
The character "h" is in front of it'
The character " " is following it.
The target "is" is found at index 5 in "This iss a test of the issue of finding is"
The character " " is in front of it'
The character "s" is following it.
The target "is" is found at index 23 in "This iss a test of the issue of finding is"
The character " " is in front of it'
The character "s" is following it.
The target "is" is found at index 40 in "This iss a test of the issue of finding is"
The character " " is in front of it'
There is no character following it
Would you like to repeat this program?
Please enter "y" for yes or "n" for no.
yes
Please enter "y" for yes or "n" for no.
y
This program identifies if a target String is contained within another String.
And, if it is there it returns the first occurrence of that String.
It also identifies the character before the found String and the character after the found String.
Please enter a target String:his
Please enter the String to be searched:Hers isnt the one
The target "his" is not found in "Hers isnt the one"
We will now check for multiple instances of the target
The target "his" is not found in "Hers isnt the one"
Would you like to repeat this program?
Please enter "y" for yes or "n" for no.
Please enter "y" for yes or "n" for no.
n
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 3 images