1 answer

Goal: Write a Python program to implement an airport take-offldeparture simulator Proiect: Consider the following tables...

Question:

Goal: Write a Python program to implement an airport take-offldeparture simulator Proiect: Consider the following tables whic
From the above three queues (one for each airline), flights will be added to a separate runway queue as aircraft exit their g
All four queues (American, Delta, Southwest and the runway) MUST be implemented using a linked list . You may work individual
Goal: Write a Python program to implement an airport take-offldeparture simulator Proiect: Consider the following tables which contain, for each airline, a queue of flights boarded and ready to take-off from BWI. Airline Flight # Destination Gate # American 127 American 322 American 233 American 742 American 112 American 437 DCA BUF 10 12 13 14 15 CAE LGA Airline Flight # 1 Destination Gate # Delta 221 SFO DET CVG SAN 20 21 Delta 348 Delta 765 Delta 612 23 24 Delta 148 Airline Flight # Destination Gate # Southwest 345 Southwest65 Southwest 211 Southwes 324 Southwest 367 Southwest 311 Southwest 375 LGA PHL BOS SFO SAN 40 41 42 43 45 Tables of Departing Flights from BWI for American, Delta and Southwest Airlines
From the above three queues (one for each airline), flights will be added to a separate runway queue as aircraft exit their gates and enter a single runway according to the following schedule 1. Every 2 seconds, generate a random number,'x', to decide which flight will be added to the runway queue a. If 0x33, add the next flight from the American Airlines queue b. If .33 <x.67, add the next flight from the Delta queue c. If .67 <= x <= 1, add the next flight from the Southwest queue d. Output a message stating which flight was added to the runway queue e. Make sure you include the possibility of an empty queue as follows i. Once an airline gate queue is empty, decide between the remaining two airlines 1. If 0 <-x <-.5, add the next flight from remaining airline #1 2. If .5 x 1, add the next flight from remaining airline #2 2. Every 4 seconds, generate a random number 'y' to testor a takeoff a. If 0y.5, a flight takes off from the runway queue b. If .5 < y <-1, an arriving flight is landing, no takeoff is allowed and the runway queue must wait another 4 seconds c. Output a message stating which flight took off or must wait d. Output a table containing the current queue of flights waiting at each airline gate e. Output a list of all flights currently in the runway queue f. Output a message when all flights have taken off. 3. After each takeoff test (i.e. every 4 seconds), generate a random number, 'z', to test for a flight cancellation a. If 0 <=z .1, remove a flight from the American queue using randint' b. If.50 z60, remove a flight from the Delta queue using 'randint c. If .80 <= z <= .90, remove a flight in the Southwest queue using randint' d. Output a message stating which flight was cancelled e. Make sure you include the possibility of an empty airline queue(i.e. if an airline queue is empty, there is no need to cancel a flight)
All four queues (American, Delta, Southwest and the runway) MUST be implemented using a linked list . You may work individually or in groups of two students if desired . Your program must be well-organized and well-documented. Your program must work and you must demonstrate project completion by including program output of a run of your simulation. Project Grading System: 10% program comments and documentation 20% program organization 70% working program output o The following commands may prove useful: import random import time #import random library #import time library random.random0 #generate a uniform random number between 0 and 1 random.randint(1,n) #generate a random integer between 1 and n time.sleep(seconds) #temporarily stop program execution filename "filename.txt" filehandle-open (filename, "w") #open a file for simulation output #file is kept open until simulation terminates filehandle.write(text on line 1in" filehandle.write('text on line 2n) filehandle.close) #close the file after simulation terminates when #no more output is required

Answers

import random
import time

class Node:
def __init__(self, data):
self.data = data
self.next = None

class Queue:
def __init__(self):
self.head = None
self.last = None

def enqueue(self, data):
if self.last is None:
self.head = Node(data)
self.last = self.head
else:
self.last.next = Node(data)
self.last = self.last.next

def dequeue(self):
if self.head is None:
return None
else:
to_return = self.head.data
self.head = self.head.next
return to_return

def getdata(self):
temp = self.head
Data = list()
while temp is not None:
Data.append(temp.data)
# print(temp.data)
temp = temp.next

return Data

def sizequeue(self):
temp = self.head
count = 0
while temp is not None:
count = count + 1
temp = temp.next

return count

def top(self):
return self.head.data

American = Queue()
Delta = Queue()
Southwest = Queue()
Runway = Queue()

American.enqueue(["American",127,"DCA",10])
American.enqueue(["American",322,"BUF",11])
American.enqueue(["American",233,"FLL",12])
American.enqueue(["American",742,"LAX",13])
American.enqueue(["American",112,"CAE",14])
American.enqueue(["American",437,"LGA",15])

Delta.enqueue(["Delta",221,"SFO",20])
Delta.enqueue(["Delta",348,"DET",21])
Delta.enqueue(["Delta",765,"CVG",22])
Delta.enqueue(["Delta",612,"SAN",23])
Delta.enqueue(["Delta",148,"FLL",24])

Southwest.enqueue(["Southwest",345,"LGA",40])
Southwest.enqueue(["Southwest",657,"PHL",41])
Southwest.enqueue(["Southwest",211,"BOS",42])
Southwest.enqueue(["Southwest",324,"SFO",43])
Southwest.enqueue(["Southwest",367,"SAN",44])
Southwest.enqueue(["Southwest",311,"LAX",45])
Southwest.enqueue(["Southwest",375,"FLL",46])


def Every2sec():
x = random.random()

Asize = American.sizequeue()
Dsize = Delta.sizequeue()
Ssize = Southwest.sizequeue()

if Asize == 0 and Dsize == 0 and Ssize == 0:
return False
if Asize and Dsize and Ssize:
if x >= 0 and x <= .33:
a = American.dequeue()
elif x > .33 and x <= .67:
a = Delta.dequeue()
else:
a = Southwest.dequeue()
else:
if Asize and Dsize:
if x >= 0 and x <= .5:
a = American.dequeue()
else:
a = Delta.dequeue()
elif Dsize and Ssize:
if x >= 0 and x <= .5:
a = Delta.dequeue()
else:
a = Southwest.dequeue()
elif Asize and Ssize:
if x >= 0 and x <= .5:
a = American.dequeue()
else:
a = Southwest.dequeue()
else:
if Asize:
a = American.dequeue()
elif Dsize:
a = Delta.dequeue()
else:
a = Southwest.dequeue()

print("Flight " + str(a[1]) + " of " + str(a[0]) + " airlines is added to Runway Queue ")
Runway.enqueue(a)

def Every4sec_takeoff():
  
y = random.random()

if y >= 0 and y <= .5:
a = Runway.dequeue()
print("Flight " + str(a[1]) + " of " + str(a[0]) + " airlines took off")
else:
a = Runway.top()
print("Flight " + str(a[1]) + " of " + str(a[0]) + " airlines is waiting")

if Runway.sizequeue() == 0:
print("All flights have taken off")
return True
Data = Runway.getdata()

print()
print("List of all flight currently in Runway queue")
print("###################################")
print("Airlines","Flight#","Destination","Gate#")
for i in Data:
print(str(i[0]) + " " + str(i[1]) + " " + str(i[2])+ " " +str(i[3]))
print("-----------------------------------")
return False

def Every4sec_cancel():
z = random.randint(1,100) / 100
a = None
if z >= 0 and z <= .1:
if American.sizequeue() == 0:
print("American airline queue Empty, no need to cancel a flight")
else:
a = American.dequeue()

if z >= .50 and z <= .60:
if Delta.sizequeue() == 0:
print("Delta airline queue Empty, no need to cancel a flight")
else:
a = Delta.dequeue()

if z >= .80 and z <= .90:
if Southwest.sizequeue() == 0:
print("Southwest airline queue Empty, no need to cancel a flight")
else:
a = Southwest.dequeue()

if a is not None:
print(str(a[0]) + " airlines flight no " + str(a[1]) + " travelling to " + str(a[2]) + " is cancelled")

while True:
  
time.sleep(2)
Every2sec()

time.sleep(2)
Every2sec()
if Every4sec_takeoff() == True:
break;
Every4sec_cancel()

.

Similar Solved Questions

1 answer
The 3.0-kg collar is released from rest at A and slides down the inclined fixed rod...
The 3.0-kg collar is released from rest at A and slides down the inclined fixed rod in the vertical plane. The coefficient of kinetic friction is 0.42. Calculate (a) the velocity v of the collar as it strikes the spring and (b) the maximum deflection x of the spring 3.0 kg 0.55 m 0.42 54 k- 3.2 kN/m...
1 answer
5. Calculate the y coordinate of the centroid the hatched area shown. 10 cm 10 cm...
5. Calculate the y coordinate of the centroid the hatched area shown. 10 cm 10 cm 16 cm 6 cm 6 20 cm...
1 answer
Events A and B are mutually exclusiv probability 0.33. e. Suppose event A occurs with probability....
Events A and B are mutually exclusiv probability 0.33. e. Suppose event A occurs with probability. 0.61 and event B occurs with a. Compute the probability that A does not occur or B does not occur b. Compute the probability that either A occurs without B occurring or A and B both occur....
1 answer
The A-frame is being hoisted into an upright position by the vertical force of F-80 lb....
The A-frame is being hoisted into an upright position by the vertical force of F-80 lb. Determine the moment of this force about the y axis passing through points A and B when the frame is in the position shown. 52 6 ft 309 6 ft...
1 answer
Winston Corporation purchased 40 percent of the stock of Fullbright Company on January 1, 20X2, at...
Winston Corporation purchased 40 percent of the stock of Fullbright Company on January 1, 20X2, at underlying book value. During the period of January 1, 20X2, through December 31, 20X4, the market value of Winston's investment in Fullbright's stock increased by $20,000 each year. The compan...
1 answer
Problem: A 1.8 cm thick layer of oil (n = 1.46) floats on top of 33...
Problem: A 1.8 cm thick layer of oil (n = 1.46) floats on top of 33 cm deep water (n = 1.33) in a rectangular bucket. When a laser beam is held at $ = 37 degrees with respect to the surface of the water, its beam enters at the edge of the bucket and strikes the base of the bucket at its center. oil ...
1 answer
1. [30 points) Let y be maximum bench press and x be the number of 60-pound...
1. [30 points) Let y be maximum bench press and x be the number of 60-pound bench presses for 65 athletes. The prediction equation is û = 60.2+1.53x. The sum of squared error equals 4212.9. (a) (15 points) Find the standard error of û when x = 11 (the mean of the x-value). (b) (5 points]...
1 answer
For which of the following substances is the standard free energy of formation not equal to...
For which of the following substances is the standard free energy of formation not equal to zero at 298 K.? A) Cr(s) B)Kr(g) C)Ce(s) D)Na(g) E)O2(g)...
1 answer
Your research on Shetland Co. stock shows the following information. Expected dividend (D1) = $3.00 Current...
Your research on Shetland Co. stock shows the following information. Expected dividend (D1) = $3.00 Current Price (PO) = $50.00 Constant Expected Growth Rate = 6.0% If the market is efficient and the stock is in equilibrium, which of the statements below is correct? Expected capital gains yield is e...
1 answer
10. What is the exact (radical) value of QR? [1 pt.] 11. What are the missing...
10. What is the exact (radical) value of QR? [1 pt.] 11. What are the missing side lengths in ATSU above? Keep your answer in simplified radical form. ST=_ [2 pts.] SU = _ _ [1 pt.] Use the figure for Problem 12. 8.4in./ 51 10.6 in 12. What is the area of the triangle to the nearest tenth of a squar...
1 answer
4 0 -2 Diagonalize C=125 4|ifpossible, or state why it is not diagonalizable. 3. lo 0...
4 0 -2 Diagonalize C=125 4|ifpossible, or state why it is not diagonalizable. 3. lo 0 5...
1 answer
Discussion Question Luther Electronics sell a variety of gadgets including tablets. The business uses a perpetual...
Discussion Question Luther Electronics sell a variety of gadgets including tablets. The business uses a perpetual inventory system and the LIFO method to account for inventory and began the third quarter of 2018 with merchandise inventory of 10 "PIXI 3G 7" tablets at a total cost of $134,200...
1 answer
The following are various management assertions (a. through m.) related to sales and accounts receivable. Management...
The following are various management assertions (a. through m.) related to sales and accounts receivable. Management Assertion Receivables are appropriately classified as to trade and other receivables in the financial statements and are clearly described. Sales transactions have been recorded in th...
1 answer
Reverse Notation Reverse Polish Notation: Translate the following equations into Reverse Polish Notation: Equations 5+7-8/(9+2) |(5+4^7)-8*9/2...
Reverse Notation Reverse Polish Notation: Translate the following equations into Reverse Polish Notation: Equations 5+7-8/(9+2) |(5+4^7)-8*9/2 (9-4+8/9^2) You do not have to code the whole thing! Just translate the equation!...
1 answer
A. Create a spreadsheet similar to Table 3.1 to model the following: (1) A multiple-step comparative...
a. Create a spreadsheet similar to Table 3.1 to model the following: (1) A multiple-step comparative income statement for Dayton Inc. for the peri- ods ending December 31, 2019 and 2018. You must calculate the cost of goods sold for the year 2019. (2) A common-size income statement for Dayton Inc. c...
1 answer
Oregon Forest Products will acquire new equipment that falls under the five-year MACRS category. The cost...
Oregon Forest Products will acquire new equipment that falls under the five-year MACRS category. The cost is $500,000. If the equipment is purchased, the following earnings before depreciation and taxes will be generated for the next six years. Use Table 12-12. Use Appendix B for an approximate answ...
1 answer
How do you write 24 thousand in scientific notation?
How do you write 24 thousand in scientific notation?...
1 answer
P2.6B (LO 2, 3, 4) AP Kiersted Financial Services was formed on November 1, 2021. During...
P2.6B (LO 2, 3, 4) AP Kiersted Financial Services was formed on November 1, 2021. During the month of November, the following events and transactions occurred: Nov. 1 Haakon Kiersted, the owner, invested $35,000 cash in the company. He also invested equipment that had originally cost Haakon $25,000 ...