Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using NetBeans. Work with the Stack data structure and explore the idea of first-in, last-out (FILO). Imagine that you're visiting a local all-you-can-eat breakfast bar;

Using NetBeans. Work with the Stack data structure and explore the idea of first-in, last-out (FILO). Imagine that you're visiting a local all-you-can-eat breakfast bar; among the many items on the bar is a pan of biscuits. Your task is to simulate the biscuit pan with a computer program. Note that when new biscuits are added to the pan, they're always added to the top (the worker just dumps new biscuits on top of the old biscuits); also note that whenever someone takes a biscuit to eat, they pick the top-most biscuit. Thus we've got a stack (first-in, last-out) and the bottom-most biscuit is always the oldest. For sake of simplicity, imagine that the pan only allows you to select a "top" biscuit (i.e. you can't pick among many). The task is to utilize a stack collection. Your program should allow the user to add a biscuit, remove a biscuit, and print the status of the stack. The stack should store the time in which the biscuit was added; and when a biscuit is removed, the program should display how long the biscuit "lived" in the pan (i.e. the difference from now to when it was added to the pan). Important items to consider: Don't allow the user to remove (pop) a biscuit if the pan is empty Displaying the status of the stack should show how many biscuits are in the stack and the "age" of the topmost biscuit Use the Stack class to make your job a LOT easier (otherwise, you must implement the stack class yourself). To get the time in Java, import java.util.* and then make use of the Date class.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Why do HCMSs exist? Do they change over time?

Answered: 1 week ago