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
Question 1 of 20 :
tekilochka [14]
With style comes difference. Style is a personal thing that will change among individuals, so B
7 0
3 years ago
Read 2 more answers
A new attack involves hacking into medical records and then offering these records for sale on the black market. A medical recor
Flura [38]

Answer:

1. Control Activities

2. Internal

Explanation:

Considering the scenario explained in the question, it can be concluded that This is an IT application of the COSO principle of CONTROL ACTIVITIES and evidence PREVENTIVE controls.

In this case, the Control Activities which is one of the five principles of COSO (Committee of Sponsoring Organizations of the Treadway Commission) is a means of selecting and developing general control over technology, through strategies and techniques. This is what the medical records company did by building controls into its systems to prevent hackers from accessing its system.

This is an example of internal CONTROL ACTIVITIES that illustrates PREVENTIVE control against potential risks or hacks.

8 0
3 years ago
How does 5G technology enhance the Internet of Things (ioT) ?
Naddik [55]

Answer:

Internet of Things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster.

Explanation:

Internet of Things are basically any everyday item that has software that connects to the internet, in which that item sends or even receives data from it connecting to different servers using an internet service.

5G is a 5th generation technology that also connects to servers through an internet service. This 5G technology allows the items to receive information faster, which overall approves the internet service. One of the proud examples of 5G technology is our modern-day phones/appliances. 5G technology allows you to connect to an internet service and send information or receive information faster than 4G technology.

For your answer, since "internet of things are everyday items that uses the internet, 5G internet enhances the internet service allowing you to connect, receive, or send information in places where internet would usually be slower like crowded areas. Through antennas using spectrum which carries information through different types of waves, it overall makes the internet service better, making the appliances on that internet service faster."

Hope this helps.

4 0
2 years ago
Which organization publishes a handbook that describes various occupations? U.S. Department of Defense U.S. Department of Agricu
prohojiy [21]

Answer:

U.S. Bureau of Labor Statistics.

Explanation:

The Bureau of Labor Statistics is a unit of the United States Department of Labor assigned with the task of fact-finding in the field of labor and statistics for the government. The agency helps measure the labor activity in the market and evaluates all forms of activity regarding labor conditions for the government.

This agency also functions or serves as the principal agency for the United States Federal Statistical System. It not only collects information or data but also helps spread the said information to the government. It also published a biennial handbook describing various occupations.

3 0
2 years ago
How do I answer a question that was answered incorrectly on Brainly
Mashcka [7]

Answer:

Explanation:

Go and ask a teacher or search

6 0
3 years ago
Read 2 more answers
Other questions:
  • Write a program which can do a String Check if its Panagram or not!
    10·1 answer
  • How to access files on different computer same network
    14·1 answer
  • In which career field would the computing technology industry associations compTIA A+ certification be useful
    6·1 answer
  • which of these describe raw data?check all of the boxes that apply A) what a person buys B) where a person lives C) data that ha
    9·1 answer
  • Which of the following is a technique used by hackers to identify unsecured wireless network locations to other hackers?A. Blues
    10·1 answer
  • Visual culture is an area of academic study that deals with the totality of images and visual objects produced in ____________,
    6·1 answer
  • To display data in a certain manner, like alphabetical order, is called
    5·2 answers
  • Numerical methods are implementations of mathematical algorithms, but constructed with special consideration for accuracy of sol
    7·1 answer
  • What is Error Code: 232011
    11·2 answers
  • The cost to ship a package is a flat fee of 75 cents plus 25 cents per pound. 1. Declare a const named CENTS_PER_POUND and initi
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!