Last program, which I have virtually nothing for. It's not that hard, but I just need to sort out what to do for it. It gets a word from a user and checks if it is a palindrone (a word which reads the same backwards and forwards, such as Anna). I know I have to set up some kind of while loop and push the letters into a stack and pop them to check if they're equal, but I need some help with my definitions, objects, etc. Not that complicated. Also, the program should ignore case, spaces, and punctuation. For example, if the term "An Na" is put in, it should compare correctly as a palindrone and the program will say "This term is a palindrone".
Edit: Here's the code I now have so far on this. I am unsure of how to push and pop the characters as opposed to the whole string into the stack, and then initialize a new string to compare it to the first one. Code:
public class Lab6 extends List
{
private String string;
//create stack
Stack stack=new Stack();
//ask user for a string
string=JOptionPane.ShowInputDialog("Enter a string: ");
//add object to stack
public synchronized void push(string)
{
insertAtFront(string);
}
//remove object from stack
public synchronized String pop() throws EmptyListException
{
return removeFromFront();
}
//compare characters in string
do
{
}
while
{
}
public static void main(String args[])