Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Mandatory Instance methods: public int size ( ) / / returns the number of values which are currently in the queue public boolean isEmpty (
Mandatory Instance methods:
public int size
returns the number of values which are currently in the queue
public boolean isEmpty
returns true only if there are no values in the queue
public void quedouble value
add the specified value into the queue
public double deQue
if the queue is not empty,
remove and returns the least currently qued value in the queue
otherwise,
returns Double.NaN
public void queueDump
print all of the values currenty in the queue, in the order that
they would be deQued from the queue
Your Class must also work with the following Driver Class StackQueueDriver:
public class StackQueueDriver
public static void mainString args
Stack myStack new Stack;
Queue myQueue new Queue;
System.out.printlnFilling Stack:";
double value;
for int s ; s ; s
value s s;
System.out.printlntpushing value;
myStack.pushvalue;
System.out.println
Stack Dump:";
myStack.stackDump;
System.out.println
Emptying Stack:";
whilemyStack.isEmpty
value myStack.pop;
System.out.printlntpop value;
System.out.println
Stack Dump:";
myStack.stackDump;
System.out.println
A pop too far myStack.pop;
System.out.println
;
System.out.printlnFilling Queue:";
for int q ; q ; q
value q q;
System.out.printlntqueing value;
myQueue.quevalue;
System.out.println
Queue Dump:";
myQueue.queueDump;
System.out.println
Emptying Queue:";
whilemyQueue.isEmpty
value myQueue.deQue;
System.out.printlntdeQue value;
System.out.println
Queue Dump:";
myQueue.queueDump;
System.out.println
A deQue too far myQueue.deQue;
And produce the following output or something equivalent:
Filling Stack:
pushing
pushing
pushing
pushing
pushing
pushing
pushing
pushing
pushing
pushing
Stack Dump:
Emptying Stack:
pop
pop
pop
pop
pop
pop
pop
pop
pop
pop
Stack Dump:
A pop too far NaN
Filling Queue:
queing
queing
queing
queing
queing
queing
queing
queing
queing
queing
Queue Dump:
array.at
array.at
array.at
array.at
array.at
array.at
array.at
array.at
array.at
array.at
Emptying Queue:
deQue
deQue
deQue
deQue
deQue
deQue
deQue
deQue
deQue
deQue
Queue Dump:
A deQue too far Na
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