May 31, 2016 09:01 AM
(This post was last modified: May 31, 2016 09:35 AM by techgeek4877.)
I need help with stacks, how would I code these questions? Thanks in advance!
1. In class StackDemo, complete the method countEven that when passed a stack of integers, returns the number of even numbers. The stack must remain unchanged after the method finishes execution. Return null if the stack is empty.
4. In class StackDemo, complete the method alternateItems that when passed a stack of integers, returns a stack containing every alternate item, starting from the top item, from the passed stack. For example, if the stack passed is [6, 3, 1, 8] (where 8 is the top item), returns the stack [3, 8], and when the stack passed is [2, 6, 3, 1, 8], returns the stack [2, 3, 8].
5. Write a method that when passed an array of integers, returns the array reversed, using a stack
1. In class StackDemo, complete the method countEven that when passed a stack of integers, returns the number of even numbers. The stack must remain unchanged after the method finishes execution. Return null if the stack is empty.
4. In class StackDemo, complete the method alternateItems that when passed a stack of integers, returns a stack containing every alternate item, starting from the top item, from the passed stack. For example, if the stack passed is [6, 3, 1, 8] (where 8 is the top item), returns the stack [3, 8], and when the stack passed is [2, 6, 3, 1, 8], returns the stack [2, 3, 8].
5. Write a method that when passed an array of integers, returns the array reversed, using a stack


