Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

  1. Be sure to import java.util.Scanner at the top of the PEX7.java file.
  2. Declare a Scanner object by passing System.in as a parameter to the Scanner constructor.
  3. Declare an GenericStack, and instantiate it as a newGenericStack.
  4. Declare an GenericQueue, and instantiate it as a newGenericQueue.
  5. Print a prompt to the user to enter a string that will be evaluated.
  6. Get a String from the Scanner object by calling its nextLine() method.
  7. Iterate through each character in the String, placing each character onto the stack as well as onto the queue.
  8. 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.
  9. Print whether the String received from the Scanner object was in fact a palindrome.
  10. 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

International Marketing And Export Management

Authors: Gerald Albaum , Alexander Josiassen , Edwin Duerr

8th Edition

1292016922, 978-1292016924

More Books

Students also viewed these Programming questions