Question
Write the GenericQueue.java file but would like to compare the other twice files i already have as well DESCRIPTION: The PEX7class should be declared as
Write the GenericQueue.java file but would like to compare the other twice files i already have as well
DESCRIPTION:
The PEX7class should be declared as a public class and should meet all the requirements listed below. Its purpose is to implement a main method which tests all of the files created in the Chapter Seven assignment. Basically, the main method should test an input string to determine whether the string is a palindrome. A palindrome is a sequence of characters that can be reversed to reveal the same sequence. For example, the word "racecar" is a palindrome; if you reverse the letters in the word "racecar", you end-up with the same word -- "racecar". The string "1234321" is also a palindrome, since the string can be reversed to reveal the same order of characters. However, the word, "cat" is not a palindrome, since the reversal of "cat" is "tac".
FILES TO BE SUBMITTED:
In this assignment students should create two Java classes called GenericStack (20 points), GenericQueue (20 points), and PEX7(60 points). The PEX7class should implement a main method which tests all of the other files created in the assignment.
. However the main method in PEX7.javamustperform the following tasks:
- Be sure to import java.util.Scanner at the top of the PEX7.java file.
- Declare a Scanner object by passing System.in as a parameter to the Scanner constructor.
- Declare an GenericStack, and instantiate it as a newGenericStack.
- Declare an GenericQueue, and instantiate it as a newGenericQueue.
- Print a prompt to the user to enter a string that will be evaluated.
- Get a String from the Scanner object by calling its nextLine() method.
- Iterate through each character in the String, placing each character onto the stack as well as onto the queue.
- Determine whether the String is a palindrome by comparing each character popped off of the stack to each character dequeued from the queue. Since the stack pops characters in the reverse order of which they were added and the queue dequeues characters in the same order in which they were added, the characters from anynormal String would not match; only a perfect palindrome would pass the test.
- Print whether the String received from the Scanner object was in fact a palindrome.
- Print a prompt, asking if the user would like to evaluate another string. If the user chooses to do so, repeat steps 5 - 10.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started