The first part is assignment 3 and the second is what finishes it. I mainly need
ID: 3842959 • Letter: T
Question
The first part is assignment 3 and the second is what finishes it. I mainly need the Queue part to make the words type backwards and forwards like the example, but the stack will help. Please help in Java language.
Step 1 Doubly Linked List Class From the lecture material create a doubly linked list class. This class should be generic so that it will operate on any given type. Your class should have the ability to add to the front, add to the rear, insert (you can insert before or after a node), delete, and find. Your list class should also implement functionality that will allow you traverse the list forward and backward. As for the naming conventions and interface into the list I wi eave all of that up to you Step 2 Stack and Queue Using the linked list class you created in Step 1 create stack and queue classes. I will leave it up to you as to whether to use composition or inheritance but whatever way you choose to go you should be able to explain why you chose the relationship type you did The stack class should have the following interface push pop peek e The queue should have the following interface enqueue dequeue peek Again I will leave it up to you as to the parameters to the functions and the return type. As usual please have goodExplanation / Answer
import java.util.Queue; import java.util.Scanner; import java.util.LinkedList; class PalindromeTest { public static void main(String[] args) { System.out.print("Enter any string:"); Scanner in=new Scanner(System.in); String inputString = in.nextLine(); Queue queue = new LinkedList(); for (int i = inputString.length()-1; i >=0; i--) { queue.add(inputString.charAt(i)); } String reverseString = ""; while (!queue.isEmpty()) { reverseString = reverseString+queue.remove(); } if (inputString.equals(reverseString)) System.out.println("The input String is a palindrome."); else System.out.println("The input String is not a palindrome."); } }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.