Question: Create, compile, and run a program that manages a stack. Specifically, your program should create a stack that holds returned library books. Library patrons will
Create, compile, and run a program that manages a stack. Specifically, your program should create a stack that holds returned library books. Library patrons will come up to your desk and give you books that they are returning. You should push these onto the stack. Library employees will, from time to time, take books from that stack and put the books back on the shelves. As the first line starts, your job is to manage that stack.
Some notes:
Your program should process at least seven books.
Do not return all books and then shelve them. Instead, interleave the returns and shelving. A suggested algorithm follows: (You dont have to follow this algorithm, but do something like it ) Suppose you have seven books. The first three are returned. Push these onto the stack. Then one is shelved. Pop this book from the stack. Two more are returned. (Push these.) Three are shelved. (Pop these.) Two more are returned. (Again, push these.) Finally, all remaining books on the stack are shelved. (Pop all of them.)
As books are being pushed onto and popped from the stack, list each book and tell what's happening to it.
Data fields are: Name,
java
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
