In the PalindromeStack class, write Java code for the following question by adding code at the comment labeled ADD YOUR
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am
In the PalindromeStack class, write Java code for the following question by adding code at the comment labeled ADD YOUR
question by adding code at the comment labeled ADD YOUR CODE HERE. /* Write a Java program that uses ArrayStack (array stack from Chapter 3) * to determine whether an input string is a palindrome. * A palindrome is a string of characters (a word, phrase, or * sentence) that is the same regardless of whether you read it * forward or backward. * Here are two sample runs: * Enter a string: abcdcba * The input string is a palindrome. * Enter a string: abcdefg * The input string is not a palindrome. */ import java.util.Scanner; public class PalindromeStack { public static void main(String[] args) { System.out.print("Enter a string: "); Scanner input = new Scanner(System.in); Strings = input.next(); // input string String t = ""; // reverse string ArrayStack stack = new ArrayStack(); // ADD YOUR CODE HERE if (s.equals(t)) System.out.println("The input string is a palindrome."); else System.out.println("The input string is not a palindrome."); } // end main } // end PalindromeStack
In the PalindromeStack class, write Java code for the following