Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I help with writing a pseudo code and uml diagram for the following code. Source Code: import java.util.Scanner; public class PalindromeDetector { public static void

I help with writing a pseudo code and uml diagram for the following code.

Source Code:

import java.util.Scanner; public class PalindromeDetector { public static void main(String args[]) { Scanner scanner= new Scanner(System.in); String userString =""; // get user input string do { System.out.println("Enter the string (enter end to quit): "); // read string userString = scanner.nextLine(); if(userString.equalsIgnoreCase("end")) { break; } // call method and check if the input string is palindrome if (palindromeCheck(userString.toLowerCase(), 0, userString.length() - 1)) { System.out.println("The input string is palindrome"); } else { System.out.println("The input string is not palindrome"); } }while(!userString.equalsIgnoreCase("end")); // close the scanner object scanner.close(); } // A recursive method to check string palindrome or not public static boolean palindromeCheck(String str, int startIndex, int endIndex) { // if there is only one character if (startIndex == endIndex) return true; // if the start and end characters different if ((str.charAt(startIndex)) != (str.charAt(endIndex))) return false; // if more than 2 characters check the mid if (startIndex < endIndex + 1) return palindromeCheck(str, startIndex + 1, endIndex - 1); return true; } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Beginning Databases With PostgreSQL From Novice To Professional

Authors: Richard Stones, Neil Matthew

2nd Edition

1590594789, 978-1590594780

More Books

Students also viewed these Databases questions

Question

\(P(-1.54

Answered: 1 week ago