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
Given below is information about a network. Choose one of the following three​ options: the network is definitely a​ tree; the n
MatroZZZ [7]

A Network is definitely a Tree when any of the below properties matched.

Explanation:

A Network is synonym for connected graph. Connected graph is a graph is a path which will connect from vertex to vertex.

A Tree is a network that has no circuit. network can be differed from tree by three key properties

1. Single path property - one path connecting two vertices

2. All bridges property - every edge of a network is a bridge

3. N-1 edges property - N vertices has N-1 edges

To determine this we use to N-1 edges property as given number of vertices and no bridges.

If a network has 15 vertices it must have 15-1= 14 edges to become a tree

4 0
3 years ago
Mary is proofreading an eBook. Sometimes she has to scroll several pages at a time. Which key on the numeric keypad will help he
Leto [7]
The number key 2 will help her scroll down.
3 0
3 years ago
Read 2 more answers
3. Which icon image is greater in file size? (Show your working) [2]
kipiarov [429]

Answer:

I would go with b. A 16 colour icon with dimensions of 100 x 100 pixels.

Explanation:

Even though the first colour icon has more colours, the second has double the pizels in the both the height and width.

Hope this answer helps!

5 0
3 years ago
2. What is software conflict?<br>​
Morgarella [4.7K]

Answer:

A problem that occurs when two programs cannot run in the same computer at the same time. It is generally due to a programming bug and typically manifests when two programs compete for the same resource (memory, peripheral device, register, etc.).

Hope it helps out!

Explanation:

3 0
2 years ago
You have a large company, and it is important to your business that your employees' work is backed up regularly. Which network w
valkas [14]
Client server network as it has a powerful server which provides all the networks required on the network. Files are usually backed up regularly.

3 0
3 years ago
Other questions:
  • Stores of data that are so large or complex that it is difficult to process them using traditional data base management applicat
    5·1 answer
  • Methods for preventing/overcoming group conflict include all EXCEPT:
    10·1 answer
  • To quit Word, click the Restore button on the right side of the title bar. <br> True <br> False
    6·1 answer
  • What are three steps to use to research relevant information on the internet? (Site 1)
    13·2 answers
  • _______ imaging technology defines locations in the brain where neurons are especially active using safe radioactive isotopes to
    8·2 answers
  • In addition to using comments and track changes, you can also use the comparison feature for reviewing documents. In this activi
    11·1 answer
  • What does resolution mean on a computer monitor?
    9·2 answers
  • You just recently opened a business that will be selling items on the Internet. You don’ t actually have a physical store that p
    13·1 answer
  • Which device do you think is the most important in the development of human civilization
    7·1 answer
  • Imagine that you are creating a website for a client. How will you interact with the client, gather requirements, and update the
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!