Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Modify the AWT model to: a) report out the largest number of customers enqueued at the same time b) assign the next arriving customer to

Modify the AWT model to:

a) report out the largest number of customers enqueued at the same time

b) assign the next arriving customer to a specific queue based on shortest finish time

c) provide a user interface control to allow user to select shortest finish time or shortest queue for assignments

create the program that is capable of answering these questions. with user inputed data such as the arrival time, service time, how many customers. then asks if the user wants to do it again with y/n:

determine a reasonable reasonable number of queues to use if there are 1000 customers and:

a) The inter-arrival time is 5 and the service time is 5

b) The inter-arrival time is 1 and the service time is 5

c) The inter-arrival time ranges from 0 to 20, and the service time ranges from 20 to 100

d) The inter-arrival time ranges from 0 to 2, and the service time ranges from 20 to 100

Average Waiting Time:

import java.util.Random;

import java.util.Scanner;

public class AveragaWaitingTime {

static int Min(int b[], int a[], int tbt, int r, int n,int large[]) {

int j = 0;

int min = tbt;

int l=0;//finding larger number of process in queue

for (int i = n - 1; i >= 0; i--) {

if (b[i] < min && b[i] > 0 && r >= a[i]) {

min = b[i];

l++;

j = i;

}

}

if(large[0]

large[0]=l;

return j;

}

static int Shortesfinishtime(int n,int p[],int at[],int bt[],int bt2[],int wt[],int tat[])

{

int tbt = 0, large[] = {0};

for (int i = 0; i < n; i++) {

tbt = tbt + bt[i];

}

int time[] = new int[tbt];

int k = 0;

int q2 = 0;

System.out.println("Gantt Chart");

System.out.print("|");

//bt[0] = bt[0] - 1;

for (int i = 0; i < tbt; i++) {

int q = Min(bt, at, tbt, i, n,large);

if (q != q2) {

System.out.print(" p[" + p[q] + "]\t|");

time[k++] = i;

wt[q] = i;

tat[q] = i + bt[q];

}

bt[q] = bt[q] - 1;

q2 = q;

}

time[k] = tbt;

System.out.println();

System.out.print("0\t");

for (int i = 0; i <= k; i++) {

System.out.print(time[i] + "\t");

}

double awt=0;//average waiting time

for(int i=0;i

{

awt=awt+wt[i];

}

awt=awt/n;

System.out.println(" AVERAGE WAITING TIME"+awt);

return large[0];//returning max number of process in queue at same time

}

static int shortestsizetime(int n,int process[],int ptime[],int wtime[])

{

int temp, total=0;

float avg=0;

for(int i=0;i

{

for(int j=i+1;j

if(ptime[i]>ptime[j])

{

temp = ptime[i];

ptime[i] = ptime[j];

ptime[j] = temp;

temp = process[i];

process[i] = process[j];

process[j] = temp;

}

}

}

wtime[0] = 0;

for(int i=1;i

{

wtime[i] = wtime[i-1]+ptime[i-1];

total = total + wtime[i];

}

avg = (float)total/n;

System.out.println("P_ID P_TIME W_TIME");

for(int i=0;i

{

System.out.println(process[i]+"\t"+ptime[i]+"\t"+wtime[i]);

}

System.out.println("Total Waiting Time: "+total);

System.out.println("Average Waiting Time: "+avg);

return n-1;

}

public static void main(String argv[])

{

//variable declaration

int n=100;//number of processes

int p[]=new int[n];

int a[]=new int[n];//to store arrival time of 100 processes

int b[]=new int[n];//to store service/burst/processing time of 100 processes

int b2[]=new int[n];//to store service/burst/processing time of 100 processes

int w[]=new int[n];//to store waiting time of 100 processes

int tat[]=new int[n];//to store turaround time of 100 processes

int i,j;

int quanta;//time slice for round robin

double round_robin,fcfs;

Scanner sc = new Scanner(System.in);

System.out.println("Enter the no of processes");

n=sc.nextInt();

System.out.println("Enter the arrival time");

for(i=0;i<=n;i++);

{

a[i]= sc.nextInt();

}

System.out.println("Enter the Burst time");

for(i=0;i<=n;i++)

{

b[i]=sc.nextInt();

if(b[i]<0){ b[i]=b2[i]=-1*b[i];}

}

Random r= new Random(); //to generate random number

//generating randomly arrival time from 0 to 100

for(i=0;i

{

p[i]=i+1;

a[i]=r.nextInt()%101; //randomly number between 0 to 100 inclusive

}

//randomly burst/processing times from 0 to 100]

for(i=0;i

{

b[i]=(int)r.nextInt()%101; //random number from 0 to 100 inclusive

b2[i]=b2[i];

if(b[i]<0){ b[i]=b2[i]=-1*b[i];}

}

String ans1="";

do

{

int c;

String ans="Y";

//Scanner sc = new Scanner(System.in);

System.out.println("Enter 1: Shortestfinish time algorithm 2: Shortest size algorithm ");

c=sc.nextInt();

if(c==1)

{

System.out.println("Shortest finish time:");

//calling shortest finish time algorithm

System.out.println("Longest number of processes in queue:"+Shortesfinishtime(n,p,a,b,b2,w,tat));

}

else

{

System.out.println("Shortest size:");

//calling shortest size algorithm

System.out.println("Longest number of process in queue:"+shortestsizetime(n,p,b,w));

}

System.out.println("Do you want to continue(y/n)");

ans1 = sc.next();

}while(ans1.equals("y"));

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 31st International Conference Dexa 2020 Bratislava Slovakia September 14 17 2020 Proceedings Part 1 Lncs 12391

Authors: Sven Hartmann ,Josef Kung ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

303059002X, 978-3030590024

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago

Question

7. List behaviors to improve effective leadership in meetings

Answered: 1 week ago

Question

6. Explain the six-step group decision process

Answered: 1 week ago