1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
LUCKY_DIMON [66]
3 years ago
10

A small grocery store has one checkout.You have been asked to write a program to simulate the grocery store as it checks out cus

tomers.YOU ARE REQURED TO USE A QUEUE TO SOLVE THE PROBLEM.The queue program (qu.py) is located on the Instructor drive.Here are some guidelines:
1. A customer gets to the checkout every 1 – 5 minutes
2. The checker can process one customer every 5 – 15 minutes (depends on how many groceries customer has 10 items or less will take 5 minutes, 11- 20 items will take 6 10 minutes, more than 20 items will take 11-15 minutes- you will need two random numbers)
3. The program should find the average wait time for customers and the number of customers left
4. Use the random number generator to get values for when customers get to the checkout and 5 You are not required to use classes, but it might make things easier than 20 items will take 11 - 15 minutes-you will need two random numbers) in the queue how long the checker will take.
Computers and Technology
1 answer:
Masteriza [31]3 years ago
5 0

Answer:

Check the explanation

Explanation:

PYTHON CODE :

#import random function

from random import randint

#class Queue declaration

class Queue:

#declare methods in the Queue

def __init__(self):

self. items = []

def isEmpty(self):

return self. items == []

def enqueue(self, item):

self.items. insert(0, item)

def dequeue(self):

return self. items. pop()

def size(self):

return len(self. items)

def getInnerList(self):

return self.items

#This is customer Queue

class Customer:

#declare methods

def __init__(self,n):

self.numberOfItems=n

def __str__(self):

return str(self. numberOfItems)

def getNumberOfItems(self):

return self. numberOfItems

#This is expresscheker customer queue

class Expresschecker:

def __init__(self,n):

self.numberOfItems=n

def __str__(self):

return str(self. numberOfItems)

def getNumberOfItems(self):

return self. numberOfItems

#Returns random checkout time, based on number of items

def checkOut(Expresschecker):

items = Expresschecker. getNumberOfItems()

if items <= 10:

return randint(2, 5)

if items <= 20:

return randint(6, 9)

return randint(10, 14)

#Initiate queue for the Expresschecker

Expresschecker = Queue()

#declare total customers

totalcheckoutCustomers = 10

#express Customers shopping..

for i in range(totalcheckoutCustomers):

#Each putting Between 1 to 25 items

randomItemsQty = randint(1, 25)

customer = Customer(randomItemsQty)

#Getting into queue for checkout

Expresschecker. enqueue(customer)

#====Now all express Customers having

#random qty of items are in Queue======

#intial time

totalTime=0

#define the size of the queue

totalcheckoutCustomers = Expresschecker. size()

#using for-loop until queue is empty check out

#the items in the express cheker queue

while not(Expresschecker. isEmpty()):

totalTime+=randint(1,5)

#Picking a customer

expresscustomer = Expresschecker. dequeue()

#Processing the customer

timeTaken = checkOut(expresscustomer)

#add the time for each custimer

totalTime+=timeTaken

#compute average waiting time

averageWaitingTime = totalTime/totalcheckoutCustomers

#display the average waiting time

print("Average waiting time for the express customer queue is "

+str(averageWaitingTime)+" minutes ")

print("Remaining Custimers in the express customer Queue is: ",

Expresschecker. size())

#Returns random checkout time, based on number of items

def checkOut(customer):

items = customer. getNumberOfItems()

if items <= 10:

return randint(1, 5)

if items <= 20:

return randint(6, 10)

return randint(11, 15)

#in

customersQueue = Queue()

totalCustomers = 20 #Change number of customers here

#Customers shopping..

for i in range(totalCustomers):

#Each putting Between 1 to 25 items

randomItemsQty = randint(1, 25)

customer = Customer(randomItemsQty)

#Getting into queue for checkout

customersQueue. enqueue(customer)

#====Now all Customers having random qty

#of items are in Queue======

totalTime=0

totalCustomers = customersQueue. size()

while not(customersQueue. isEmpty()):

totalTime+=randint(1,5)

#Picking a customer

customer = customersQueue. dequeue()

#Processing the customer

timeTaken = checkOut(customer)

totalTime+=timeTaken

#Result=============================

averageWaitTime = totalTime/totalCustomers

print("Average wait time for the customer queue is

"+str(averageWaitTime)+" minutes ")

print("Remaining Customers in the customer Queue is:

",customersQueue. size())

You might be interested in
What tool can help discover and report computer errors when you first turn on a computer and before the operating system is laun
Vlada [557]

Answer:

a post diagnostic

Explanation:

4 0
2 years ago
Read 2 more answers
Plz..... Add the following Binary numbers 1. 111000 + 1100 + 111111​
Korvikt [17]

Answer:

11000011

Explanation:

This is because of the rules of bas 2

3 0
2 years ago
The definition of an "analog device" is that it is a type of _____.
sveta [45]
ITS C hope it helps goo luck!
5 0
2 years ago
A consumer is the name for:
hodyreva [135]

Answer:

A. a person who buys and uses products and services

7 0
3 years ago
Read 2 more answers
As a member of the accounting group,
Anastasy [175]

Answer:

rtg

Explanation:

rth

3 0
3 years ago
Other questions:
  • Pete Jones, a bait shop owner, incorporates ______ within a webpage to entice customers to buy a new lure.
    7·1 answer
  • When employees are hired, they agree to only use cell phones during breaks. How would you classify this?
    13·2 answers
  • When you first start your computer, which software will have to start first?
    5·2 answers
  • Why are computer messages encapsulated?
    13·1 answer
  • How do you delete a slide from your presentation after selecting it
    8·1 answer
  • Convert hexadecimal number 1AF2 to a decimal number.
    7·1 answer
  • Hello Answerers it would be great if you could answer this:
    12·2 answers
  • 2. Select the things you can do when working with rows in columns in a spreadsheet:
    5·1 answer
  • Which of the examples is part of client-side code?
    12·1 answer
  • Can someone please help me answer the extension activity and the exit ticket. I’ll award you. Thanks❤️.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!