Use the Average Waiting Time program to determine a reasonable number of queues
ID: 3803687 • Letter: U
Question
Use the Average Waiting Time program to determine a reasonable number of queues to use if there are 1000 customers and:
a) The inner-arrival time is 5 and the service time is 5
b) The inner-arrival time is 1 and the service time is 5
c) The inner-arrival time ranges from 0 to 20, and the service time ranges from 20 to 100
d) The inner-arrival time ranges from 0 to 2, and the service time ranges from 20 to 100
AWT model
public class GlassQueue<T> extends ArrayUnbndQueue<T>
public class ArrayUnbndQueue<T> implements UnboundedQueueInterface<T>
public interface UnboundedQueueInterface<T> extends QueueInterface<T>
{
void enqueue(T element);
//Adds element to the rear of this quee.
}
public interface QueueInterface<T>
{
T dequeue() throws QueueUnderflowException;
//Throws QueueUnderflowException if this queue is empty;
//otherwise, removes front element from this queue and returns it
boolean isEmpty();
//Returns true if this queue is empty; otherwise, return false
}
description of the AWT model
description of the assignment based on:
Identify which of the authors' classes used for their Average Waiting Time (AWT) model is responsible for each of the seven items identified in #42.
Use the AWT model to determine a reasonable number of queues needed to serve a thousand customers, under four different scenarios specified in #43.
Modify the AWT model to:
report out the largest number of customers enqueued at the same time
assign the next arriving customer to a specific queue based on shortest finish time
provide a user interface control to allow user to select shortest finish time or shortest queue for assignments
Explanation / Answer
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include<stdio.h>
int main()
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0; //waiting time for initial method is zero
//calculate waiting time
for(i=1;i<n;i++)
avg_wt=total/n; //average waiting time
total=0;
printf(" Process Burst Time Waiting Time Turnaround Time");
for(i=0;i<n;i++)
turnaround
total+=tat[i];
printf(" P[%d] %d %d %d",p[i],bt[i],wt[i],tat[i]);
}
avg_tat=total/n; //average turnaround
printf(" Average Waiting Time=%d",avg_wt);
printf(" Average Turnaround Time=%d ",avg_tat);
return 0;
}
C++ Program
#include<iostream>
using namespace std;
int main()
{
int bt[20],p[20],wt[20],tat[20],pr[20],i,j,n,total=0,pos,temp,avg_wt,avg_tat;
cout<<"Enter Total variety of Process:";
cin>>n;
cout<<" Enter Burst Time and Priority ";
for(i=0;i<n;i++)
{
cout<<" P["<<i+1<<"] ";
cout<<"Burst Time:";
cin>>bt[i];
cout<<"Priority:";
cin>>pr[i];
p[i]=i+1; //contains method variety
}
//sorting burst time, priority and method variety in ascending order mistreatment choice type
for(i=0;i<n;i++)
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0; //waiting time for initial method is zero
//calculate waiting time
for(i=1;i<n;i++)
avg_wt=total/n; //average waiting time
total=0;
cout<<" Process Burst Time Waiting Time Turnaround Time";
for(i=0;i<n;i++)
turnaround
total+=tat[i];
cout<<" P["<<p[i]<<"] "<<bt[i]<<" "<<wt[i]<<" "<<tat[i];
}
avg_tat=total/n; //average turnaround
cout<<" Average Waiting Time="<<avg_wt;
cout<<" Average Turnaround Time="<<avg_tat;
return 0;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include<iostream>
using namespace std;
int main()
{
int bt[20],p[20],wt[20],tat[20],pr[20],i,j,n,total=0,pos,temp,avg_wt,avg_tat;
cout<<"Enter Total variety of Process:";
cin>>n;
cout<<" Enter Burst Time and Priority ";
for(i=0;i<n;i++)
{
cout<<" P["<<i+1<<"] ";
cout<<"Burst Time:";
cin>>bt[i];
cout<<"Priority:";
cin>>pr[i];
p[i]=i+1; //contains method variety
}
//sorting burst time, priority and method variety in ascending order mistreatment choice type
for(i=0;i<n;i++)
temp=pr[i];
pr[i]=pr[pos];
pr[pos]=temp;
temp=bt[i];
bt[i]=bt[pos];
bt[pos]=temp;
temp=p[i];
p[i]=p[pos];
p[pos]=temp;
}
wt[0]=0; //waiting time for initial method is zero
//calculate waiting time
for(i=1;i<n;i++)
avg_wt=total/n; //average waiting time
total=0;
cout<<" Process Burst Time Waiting Time Turnaround Time";
for(i=0;i<n;i++)
turnaround
total+=tat[i];
cout<<" P["<<p[i]<<"] "<<bt[i]<<" "<<wt[i]<<" "<<tat[i];
}
avg_tat=total/n; //average turnaround
cout<<" Average Waiting Time="<<avg_wt;
cout<<" Average Turnaround Time="<<avg_tat;
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.