Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with this Python Exercise PLEASE DO NOT COPY CODE FROM OTHER QUESTIONS POSTED WITH THIS. Follow the steps provided below: Create a simple

Need help with this Python Exercise

PLEASE DO NOT COPY CODE FROM OTHER QUESTIONS POSTED WITH THIS.

Follow the steps provided below:

Create a simple multi-thread program in PYTHON(ONLY) to simulate a checkout in grocery store/supermarket.

The process of simulation will last for T1 seconds.

You do not need to consider thread safety.

An integer sequence t is used to record the remaining waiting time for each customer.

One thread which runs every one second is used to simulate the processing of the checkout.

(1) Reduce the remaining processing time of the first customer by one.

(2) Remove the first customer if his remaining processing time reaches zero.

(3) Clean the screen and show the new remaining processing time. 4.

Another thread is used to generate one new customer every T2 seconds.

(1) The new customer will leave the supermarket if he or she needs to join a queue with more than R customers.

(2) The processing time for the new customer is a random integer in [Tmin; Tmax) 5.

An example program run is shown as follows.

Checkout: 3 12 45 5 61, after one second, we have:

Checkout: 2 12 45 5 61, after one second, we have:

Checkout: 1 12 45 5 61 22, after one second, we have:

Checkout: 12 45 5 61 22, after one second, we have:

Checkout: 11 45 5 61 22

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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