Question: Assignment: (Class options pasted below) PLEASE ENSURE THE PROGRAM RUNS WITHOUT ERRORS. A palindrome is any word, phrase, or sentence that reads the same forward
Assignment: (Class options pasted below) PLEASE ENSURE THE PROGRAM RUNS WITHOUT ERRORS.
A palindrome is any word, phrase, or sentence that reads the same forward and backward. For example:
Able was I ere I saw Elba Desserts I stressed Kayak abcde edcba
Write a program that uses a stack to determine if a string of characters is a palindrome. This program will ask the user to enter a string, then printout a statement indicating whether or not the string was a palindrome.
Your program should treat all letter characters as lower case. Remember, spaces are characters also.
You may use any data structure you wish to create the stack so long as the stack is implemented and used correctly. Do not use any of classes in the Java API. You may use any of the class files in the wk4.zip file.
Name your demo class (containing the main method) PalindromeDemo.
/** An interface for the ADT stack. @author Frank M. Carrano @version 4.0 */ public interface StackInterface
import java.util.EmptyStackException; /** A class of stacks whose entries are stored in a chain of nodes. @author Frank M. Carrano and Timothy M. Henry @version 4.0 */ public class LinkedStack
private class Node { private T data; // Entry in stack private Node next; // Link to next node private Node(T dataPortion) { this(dataPortion, null); } // end constructor private Node(T dataPortion, Node linkPortion) { data = dataPortion; next = linkPortion; } // end constructor private T getData() { return data; } // end getData private void setData(T newData) { data = newData; } // end setData private Node getNextNode() { return next; } // end getNextNode private void setNextNode(Node nextNode) { next = nextNode; } // end setNextNode } // end Node } // end LinkedStack
/** A class of stacks whose entries are stored in an array. @author Frank M. Carrano and Timothy M. Henry @version 4.0 */ public class ArrayStack
import java.util.Vector; /** A class of stacks whose entries are stored in a vector. @author Frank M. Carrano and Timothy M. Henry @version 4.0 */ public class VectorStack
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
