n the PalindromeStack class, write Java code for the following question by adding code at the comment labeled ADD YOUR C

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

n the PalindromeStack class, write Java code for the following question by adding code at the comment labeled ADD YOUR C

Post by answerhappygod »

n the PalindromeStack class, write Java code for the followingquestion by adding code at the comment labeled ADD YOUR CODEHERE.
/* Write a Java program thatuses ArrayStack (array stack fromChapter 3)
* to determine whether an input stringis a palindrome.
* A palindrome is a string of characters(a word, phrase, or
* sentence) that is the same regardlessof 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 apalindrome.
*/
import java.util.Scanner;
public class PalindromeStack {
public static voidmain(String[] args) {
System.out.print("Enter a string:");
Scanner input = newScanner(System.in);
String s =input.next(); // input string
String t =""; // reverse string
ArrayStack stack =new ArrayStack();
// ADD YOUR CODEHERE
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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply