Question
you need to use the code below , to add this >>> Write a method that takes a string of characters as a parameter and
you need to use the code below , to add this >>> Write a method that takes a string of characters as a parameter and return true if the string is a palindrome and false otherwise. Your method should use a queue and stack to check the string. Test your method by reading a string from the keyboard and passing it to the method. Hint: in the method, store a copy of the string in a stack and another copy in a queue and compare.
------------------------------------------------------------------------------------------------------------
import java.util.*; public class testReverseQueue{ static Scanner console = new Scanner(System.in); public static void main(String[] args) { ArrayQueue myQueue = new ArrayQueue(100); int num; while(true){ System.out.print("Enter an integer value (999 to stop): "); num = console.nextInt(); if(num==999) break; myQueue.enqueue(num); } System.out.println("Content of myQueue befor reversing: "); System.out.println(myQueue.toString()); reverseQueue(myQueue); System.out.println("queue content after reversing:"); System.out.println(myQueue.toString()); } // End of main public static void reverseQueue(ArrayQueue Q){ int q_size; q_size=Q.size(); ArrayStack tempStack = new ArrayStack(q_size); for(int i=0; i
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