Question: JAVA HELP PLEASE 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()
JAVA HELP PLEASE
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 second word in the output?
Question 4 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
