Question

In: Computer Science

Write a FORTRAN program to simulate the daily activity at a gas station. Assuming that one...

Write a FORTRAN program to simulate the daily activity at a gas station. Assuming that one customer is served every six minutes, what is the average waiting time per customer?

Solutions

Expert Solution

SOLUTION :

This is a problem in discrete simulation. A random number generator is used in the program to model the arrival of customers. Since the gas station attendant cannot know if the stream of customers will be continuous, randomness of arrivals is assumed.
To calculate the average waiting time, the program should compute the waiting time of each individual car, add the times, and divide that sum by the total number of cars. The first arrival incurs no waiting time, but all subsequent arrivals must wait six minutes for each car in front of them. To obtain an average the service time remaining for each car, the total waiting time for all the cars, and the number of cars that are lined up must be found.
For each simulated minute, the program must reduce the service time SERV by one and check to see if another car has arrived. If so, the waiting time for that last car is given by SERV. WAIT - the total waiting time, is increased by adding SERV to it, while the number of cars, CARTOT, is Increased by one, and SERV is increased by six minutes. The parameter N is the number of minutes to be simulated (N cannot contain more than 6 digits).
Another assumption made is that customers arrive each minute with a probability of 0.1. To simplify the problem, it is assumed that there is only one gas pump at this station.
Note, that several values of N can be entered in the DATA section. The program procedure will be done for each of those time intervals. In order to end the program, enter N ≤ 0 as the last value.
C GASOLINE LINE SIMULATION

INTEGER WAIT, SERV, CARTOT, TIME

5 READ (5,1)N

1 FORMATE (I6)

C DO WHILE N GREATER THAN ZERO

IF (N. LE. 0) GO TO 99

SERV = 0

WAIT = 0

CARTOT = 0

DO 10 TIME = 1,N

SERV = MAX (SERV − 1,0)

22 2 CALL RAND (X)

IF (X.GT.0.1) GO TO 22

CARTOT = CARTOT + 1

WAIT = WAIT + SERV

SERV = SERV + 6

10 CONTINUE

AVWAIT = FLOAT (WAIT)/FLOAT (CARTOT)

WRITE (6,101) CARTOT,AVWAIT

101 FORMAT (IX,'AVERAGE WAIT FOR EACH OF THE',

16,'CUSTOMERS IS', F6.2,'MINUTES.')

GO TO 5

C END DO-WHILE

99 STOP

END


Related Solutions

A gas station wants a program to keep track of sales. Your gas station sells diesel...
A gas station wants a program to keep track of sales. Your gas station sells diesel for 107.9 cents per litre and regular gas for 112.9 cents per litre. Have the user enter the type of fuel (1 = Regular gas, 2 = Diesel) and number of litres sold. Print out a total for each sale (remember fuel prices already include the GST). Once you enter a 0 for the type of fuel your program should stop and print out...
Suppose that the daily demand for regular gasoline at a gas station is normally distributed with...
Suppose that the daily demand for regular gasoline at a gas station is normally distributed with a mean of 1,000 gallons and a standard deviation of 100 gallons. The next delivery of gasoline is scheduled later today at the close of business. What is the minimum amount of regular gasoline that the station must have in storage so that there is a 90% chance it will have enough to satisfy today’s demand? Select one: a. 836 b. 872 c. 1,128...
Write a Fortran program that is able to read in the data file. The file has...
Write a Fortran program that is able to read in the data file. The file has lines with the structure: 19990122 88888 30.5 Where: i) the first is an 8 digit code with the date: yyyymmdd (yyyy is the year, mm is the month, and dd is the day) ii) the second is the five digit odometer reading of a car iii) the third is the amount of fuel put into the car on that date to fill the tank...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a...
*****For C++ Program***** Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7...
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
Write a program to simulate the Distributed Mutual Exclusion in ‘C’.
Write a fortran 90 program that sets up a 4x4 2D real array A and associate...
Write a fortran 90 program that sets up a 4x4 2D real array A and associate a single value pointer AP with element (2,1) of that array. Set all elements in A equal to 0. and print the value of AP to the screen. Next set all elements in A equal to 1.23 and print the value AP to the screen.
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
One file java program that will simulate a game of Rock, Paper, Scissors. One of the...
One file java program that will simulate a game of Rock, Paper, Scissors. One of the two players will be the computer. The program will start by asking how many winning rounds are needed to win the game. Each round will consist of you asking the user to pick between rock, paper, and scissors. Internally you will get the computers choice by using a random number generator. Rock beats Scissors, Paper beats Rock, and Scissors beats Paper. You will report...
Overview For this assignment, write a program that uses functions to simulate a game of Craps....
Overview For this assignment, write a program that uses functions to simulate a game of Craps. Craps is a game of chance where a player (the shooter) will roll 2 six-sided dice. The sum of the dice will determine whether the player (and anyone that has placed a bet) wins immediately, loses immediately, or if the game continues. If the sum of the first roll of the dice (known as the come-out roll) is equal to 7 or 11, the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT