how would I change method so that it considers all characters not just letter pu
ID: 3862489 • Letter: H
Question
how would I change method so that it considers all characters not just letter public class PalindroneCLI public static void main(String[] args) Scanner Scan new Scanner (System. in); String candidate null; string to be evaluated final string STOP "X" end of input while (!sTOP .equals (candidate)) Get next candidate string to be processed. candidate "String STOP to stop) scan STOP .equals (candidate)) if obtain and output result palindrome testing. system. test (candidate) else a palindrome. An system out.printun is NOT a palindrome n");Explanation / Answer
If you use below implementation of Palindrome class, every string of any set of characters will be considered not just letters.
class Palindrome
{
public static boolean test(String str)
{
StringBuilder s = new StringBuilder(str);
if(s.equals(s.reverse()))
return true;
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.