Complete the printPalindrome method in the provided Palindrome.java program.
The printPalindrome method accepts a String as a parameter and prints whether the parameter String is a palindrome (i.e., reads the same forwards as it does backwards, for example, "abba" or "racecar").
Make the code case-insensitive, so that words like "Abba" and "Madam" will be considered palindromes.
import java.util.*;
/**
* Determines if a user entered String is a palindrome, which means
the String
* is the same forward and reverse. The determination is
case-insensitive.
* Spaces and punctuation must match for palindromes.
*
*/
public class Palindrome {
/**
* Starts program
*
* @param args array of command line arguments
*/
public static void main(String[] args) {
printPalindrome("abba");// palindrome
printPalindrome("racecar");// palindrome
printPalindrome("Madam");// palindrome
printPalindrome("!!!Hannah!!!");// palindrome
printPalindrome("! ! ! Hannah ! ! !");// palindrome
printPalindrome("Dot saw I was tod");// palindrome
printPalindrome("Step on no pets");// palindrome
printPalindrome("Step on no pets!"); // NOT
printPalindrome("dog"); // NOT
printPalindrome("Java"); // NOT
printPalindrome("abca"); // NOT
System.out.println("\n*****Read from User*****");
readConsole();
}
/**
* Reads user's console input and prints the results
*/
public static void readConsole() {
Scanner in = new Scanner(System.in);
System.out.print("Enter a word or phrase: ");
String text = in.nextLine();
printPalindrome(text);
}
/**
* Prints whether text is a palindrome
* @param text String to check whether it is a palindrome
*/
public static void printPalindrome(String text) {
System.out.print("\nisPalindrome: \t");
//create a String that is the reverse of text
String reverse = "";
// if text equals reversed text (remember to ignore case) then
print:
System.out.println("\"" + text + "\" is a palindrome");
// otherwise print:
System.out.println("\"" + text + "\" is NOT a palindrome");
}
}
import java.util.*;
/**
* Determines if a user entered String is a palindrome, which means the String
* is the same forward and reverse. The determination is case-insensitive.
* Spaces and punctuation must match for palindromes.
*
*/
public class Palindrome {
/**
* Starts program
*
* @param args array of command line arguments
*/
public static void main(String[] args) {
printPalindrome("abba");// palindrome
printPalindrome("racecar");// palindrome
printPalindrome("Madam");// palindrome
printPalindrome("!!!Hannah!!!");// palindrome
printPalindrome("! ! ! Hannah ! ! !");// palindrome
printPalindrome("Dot saw I was tod");// palindrome
printPalindrome("Step on no pets");// palindrome
printPalindrome("Step on no pets!"); // NOT
printPalindrome("dog"); // NOT
printPalindrome("Java"); // NOT
printPalindrome("abca"); // NOT
System.out.println("
*****Read from User*****");
readConsole();
}
/**
* Reads user's console input and prints the results
*/
public static void readConsole() {
Scanner in = new Scanner(System.in);
System.out.print("Enter a word or phrase: ");
String text = in.nextLine();
printPalindrome(text);
}
/**
* Prints whether text is a palindrome
* @param text String to check whether it is a palindrome
*/
public static void printPalindrome(String text) {
System.out.print("
isPalindrome: ");
//create a String that is the reverse of text
text = text.toLowerCase();
String reverse = "";
for(int i = 0;i<text.length();i++){
reverse = text.charAt(i) + reverse;
}
// if text equals reversed text (remember to ignore case) then print:
if(text.equals(reverse))
System.out.println(""" + text + "" is a palindrome");
// otherwise print:
else
System.out.println(""" + text + "" is NOT a palindrome");
}
}

isPalindrome: "abba" is a palindrome isPalindrome: "racecar" is a palindrome isPalindrome: "madam" is a palindrome isPalindrome: "!!!hannah!!!" is a palindrome isPalindrome: "! ! ! hannah ! ! !" is a palindrome isPalindrome: "dot saw i was tod" is a palindrome isPalindrome: "step on no pets" is a palindrome isPalindrome: "step on no pets!" is NOT a palindrome isPalindrome: "dog" is NOT a palindrome isPalindrome: "java" is NOT a palindrome isPalindrome: "abca" is NOT a palindrome *****Read from User***** Enter a word or phrase: Madam isPalindrome: "madam" is a palindrome

Complete the printPalindrome method in the provided Palindrome.java program. The printPalindrome method accepts a String as...
A palindrome is a word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. In this program, ask the user to input some text and print out whether or not that text is a palindrome. Create the Boolean method isPalindrome which determines if a String is a palindrome, which means it is the same forwards and backwards. It should return a boolean of whether or not it was a palindrome. Create the method reverse...
Consider the following sample program: import java.util.Scanner; public class Palindrome { public static void main(String[] args){ Scanner kb = new Scanner(System.in); System.out.println("Enter a word:"); String word = kb.next(); String reverse = ""; for (int i=word.length()-1; i>=0; i--) reverse += word.charAt(i); boolean result = reverse.equalsIgnoreCase(word); if (result) System.out.println("The word " +word+ " is a Palindrome."); else System.out.println("The word " +word+ " is not a Palindrome."); } } Rewrite the program so that the main method is: public static void...
A palindrome is a word, phrase, number, or other sequence of characters which reads the same backward as forward, such as madam or racecar. Write a recursive method in java that accepts a integer as its argument and returns true if it is palindrome, false otherwise. public class Recursion { public static void main(String[] args) { Recursion r = new Recursion(); System.out.println(“Is 12321 a palindrome? “+ra.isPalindrome(12321)); //true } public Boolean isPalindrome(int num){ return false;...
Exercise 1 Write a recursive method to check if a string is palindrome. public static boolean isPalindrome(String s) { A Palindrome String is string which reads the same backward as forward, such as madam or racecar
IN JAVA. Implement a method, public static boolean isPalindrome(String) to determine whether the specified String is a palindrome or not. A palindrome is a phrase that reads the same forwardand backward; not including punctuation, spaces, or letter case. Some example palindromes include: Just the method please..
Finish the given ProcessFile.java program that prompts the user for a filename and reprompts if file doesn’t exist. You will process through the file skipping any text or real (double) numbers. You will print the max, min, sum, count, and average of the integers in the file. You will want to create test files that contain integers, doubles, and Strings. HINT: Use hasNextInt() method and while loop. You may also want to use Integer.MAX_VALUE and Integer.MIN_VALUE for the initialization of...
WRITTEN IN JAVA Complete the method printIndices that accepts a String source and a character search, and prints the position of each occurrence of the search value in source. For example: Input: source = "String Programming in Java is fun", search = 'i' Console Output: 3 15 19 27 Template provided from question: public static int printIndices(String source, char search) { } public static void main(String[] args) { System.out.println("Expected printIndices() prints indices 3...
Write a program that stores a phrase as an array of words, and then prints it backwards. The main method calls method getInput , which asks the user how many words there are, stores them in an array, and returns this array. printBackwards then takes this array of words, and prints it in reverse. Code Example: import java.util.Scanner; public class L17Num1{ public static void main(String[] args) { String[] sArray=getInput(); printBackwards(sArray); } public static String[] getInput() { System.out.println("How many...
In Java This is the method we did in class. How do I reverse the string "monday"? If I could get the string "onday" reversed (to produce "yadno" then all I have to do is append the first character to make "yadnom". import java.util.Scanner; public class Lab12Num2 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); String s=sc.nextLine(); System.out.println("The string entered was " + s); System.out.println("The string printed backwards is "+ printBackwards(s)); } public static String printBackwards(String one)...
Your program must prompt the user to enter a string. The program must then test the string entered by the user to determine whether it is a palindrome. A palindrome is a string that reads the same backwards and forwards, such as "radar", "racecar", and "able was I ere I saw elba". It is customary to ignore spaces, punctuation, and capitalization when looking for palindromes. For example, "A man, a plan, a canal. Panama!" is considered to be a palindrome....