Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that tracks people who borrow a single piece of equipment for 1 hour. Repeatedly ask the user for a name (or quit

Write a program that tracks people who borrow a single piece of equipment for 1 hour. Repeatedly ask the user for a name (or quit to terminate) and the current time of the request, in 24-hour format. After each person and time are entered, do the following: Please follow all instructions!

a. Store the names and ending times (when the person will be done) in String and Integer Queues, respectively. Though not recommended, you may also try to make a custom class that stores the name and time together, allowing you to use a single Queue. However, you should know how to work with multiple Queues.

b. Remove all names and ending times from the Queues for which the ending time is earlier (less) than or equal to the current time.

c. Print the name of each person when they are removed.

d. Add each new person to the Queues using an appropriate ending time. If the Queues are empty, the ending time should be the current time +100 (which is 1 hour in 24-hour format). If the Queues are not empty, the ending time should be the last ending time +100. Note that you will need to store the last ending time in a separate variable because you cannot peek() at the end of the Queue.

e. Print the time when each person can borrow the equipment.

Include an example of your program input/output. Below is an example with program input/output and comments about what should be happening in the program:

image text in transcribed

Example Output (user input in bold Comments: Enter name (or 'quit'): Annie Enter current time: 900 Annie can have it now! Queues are empty. Annie will be done at 1000 Enter name (or 'quit'): Betty Enter current time: 930 Betty can have it at 1000 Annie isn't done yet. Betty will be done at 1100 Enter name (or 'quit'): Charles Enter current time: 1045 Annie is done, but Betty isn't. Charleswill be done at 1200 nie is done Charles can have it at 1100 Enter name (or 'quit'): Danny Enter current time: 1215 Betty is done. Charles is done. Danny can have it now! Betty and Charles are done. Danny will be done at 1315 Enter name (or 'quit'): quit

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

Step: 3

blur-text-image

Ace Your Homework with AI

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

Get Started

Students also viewed these Databases questions

Question

=+ (c) Show that if & is countable, then f(. ) is countable.

Answered: 1 week ago