Question: JAVA HELPPPP PLEASE Consider the example from section 1.3 below: StackOfStrings s = new StackOfStrings(); while (!StdIn.isEmpty()) { String item = StdIn.readString(); if (!item.equals(-)) s.push(item);
JAVA HELPPPP PLEASE
Consider the example from section 1.3 below:
StackOfStrings s = new StackOfStrings(); while (!StdIn.isEmpty()) { String item = StdIn.readString(); if (!item.equals("-")) s.push(item); else if (s.isEmpty()) StdOut.println("BAD INPUT"); else StdOut.print(s.pop() + " "); } Suppose the input is " one two three - four five - - six - seven " What would be the third word in the output?
Question 7 options:
|
| two |
|
| three |
|
| four |
|
| six |
|
| none of these |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
