Respuesta :
Answer:
The programming language is not stated;
However, I'll answer this question using Java Programming Language;
The method is as follows;
public static void isPalindrome(String userinput)
{
String reverse = "";
int lent = userinput.length();
int j = lent - 1;
while(j >= 0)
{
reverse = reverse + userinput.charAt(j);
j--;
}
if(reverse.equalsIgnoreCase(userinput))
{
System.out.println("True");
}
else
{
System.out.println("False");
}
}
Explanation:
This line defines the method isPalindrome with a string parameter userinput
public static void isPalindrome(String userinput) {
This line initializes a string variable
String reverse = "";
This line gets the length of the userinput
int len = userinput.length();
The following while-loop gets the reverse of userinput and saved the reversed string in reverse
int j = lent - 1;
while(j >= 0)
{
reverse = reverse + userinput.charAt(j);
j--;
}
The following if statement checks if userinput and reverse are equal (cases are ignored)
if(reverse.equalsIgnoreCase(userinput))
{
System.out.println("True"); This line is executed if the if condition is true
}
else
{
System.out.println("False"); This line is executed if otherwise
}
} The method ends here