Question: We'll say that a triple in a string is a char appearing three times in a row. Define a method countTriple so it will turn
We'll say that a "triple" in a string is a char appearing three times in a row. Define a method countTriple so it will turn the index of the LAST triple occurrence; otherwise, return For example
countTripleabcUUUabUUUc will return since the last triple U starts at index
countTriplexxabyyyyycd will return since the last triple y is at index
countTriplea will return since no triple was found
countTripleabbccb will return since no triple was found
Starter
public class Triple
First define countTripleString s to find whether a char appearing three times in a row in a given string s It should turn the beginning index of the LAST triple; otherwise, return Hint: use looping and chartAtint to get the character and compare.
Then complete the main
use Scanner to get user input of a String
invoke countTriple based on the result, display a message that says LAST triple appeared at the index replace x with the actual char, with the returned index that character could be retrieved or a message that says No Triple
end of class
PLEASE DO THE FOLLOWING IN JAVA
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
