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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!