Question
Create a java program where it asks the user to enter an array of values(5 elements only). After it asks the user for the integer
Create a java program where it asks the user to enter an array of values(5 elements only). After it asks the user for the integer values, ask the user what operation they want to use in a stack (the options are pop, push, and pointer). Once the user chooses the stack operation, the computer will print out the value that was popped, pushed, or pointed. If the computer can no longer do the stack operation, print out Error cannot pop, push, or pop. Also, put the stack operations in methods.
Example of Output:
Enter interger Values:
1,2,3,4,5
What operation do you want?
pop
Value popped is 5
What operation do you want?
push
What value to push(adding new value)?
6
What operation do you want?
push
Error: Stack full cannot push
What operation do you want?
pop
Error: Stack empty. cannot pop.
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