icon

UseTopicwritingscode to get 5% OFF on your first order!

Palindrome Tester (Using Java Queue)

Purpose

The purpose of this project is to practice with using and implementing Queues.

Objective

You are to implement a program to test to see if the entered word is a palindrome. A palindrome in this case is a word that reads the same backward as it does forward. Your program should take in a word from the user and store the word character by character onto a queue. Queues use the FIFO (First in first out) method to access and add data elements. You should use the java.util.Queue to implement the built in queue for this project. Once all the characters are in the queue you should then remove the characters one by one from the queue and store them in a string. Next you should print out the reverse of the word that is entered. Then print out whether or not the word that was entered by the user was a palindrome or not. Your program should loop until the word exit is typed in.

Instructions

1. Implement the java.util.Queue that is built into Java.
2. Take in a word from the user.
3. Print out the word in reverse.
4. Check to see if the word is a palindrome.
5. Print out whether or not the word is a palindrome.
6. Loop continuously until the word exit is typed in. At which time the program should exit.
7. Your output should look similar to my sample output below.
8. Zip up the files and submit them on Brightspace under the correct assignment.

Sample Output:

Enter any word to see if it is a Palindrome:
civic
The word in reverse is: civic
The word is a palindrome.
Enter any word to see if it is a Palindrome:
potato
The word in reverse is: otatop
The word is not a palindrome.
Enter any word to see if it is a Palindrome:
kayak
The word in reverse is: kayak
The word is a palindrome.
Enter any word to see if it is a Palindrome:
racecar
The word in reverse is: racecar
The word is a palindrome.
Enter any word to see if it is a Palindrome:
aaron
The word in reverse is: noraa
The word is not a palindrome.
Enter any word to see if it is a Palindrome:
exit
Exiting …

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by WordPress | Designed by: Premium WordPress Themes | Thanks to Themes Gallery, Bromoney and Wordpress Themes