Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using java Create a simple queue class and a simple stack class. The queue and s

ID: 3863070 • Letter: U

Question

Using java Create a simple queue class and a simple stack class. The queue and stack should be implemented as a linked list.

Create three functions that utilize these data structures

Write a function that opens a text file and reads its contents into a stack of characters. The program should then pop the characters from the stack and save them in a second text file. The order of the characters saved in the second file should be the reverse of their order in the first file.

Write a function that opens a text file and reads its contents into a queue of characters. The program should then dequeue each character, convert it to uppercase, and store it in a second file.

Write a function that opens two text files and reads their contents into two separate queues. The program should then determine whether the files are identical by comparing the characters in the queues. When two nonidentical characters are encountered, the program should display a message indicating that the files are not the same. If both queues contain the same set of characters, a message should be displayed indicating that the files are identical. Create a driver program to test the functions.

Explanation / Answer

import java.util.*; /* Class stackUsingQueue */ class stackUsingQueue { Queue q ; Queue tmp ; /* Constructor */ public stackUsingQueue() { q = new LinkedList(); tmp = new LinkedList(); } /* Function to push an element to the stack */ public void push(int data) { /* if no element is present in queue q then * enqueue the new element into q */ if (q.size() == 0) q.add(data); else { /* if elements are present in q then * dequeue all the elements to * temporary queue tmp */ int l = q.size(); for (int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote