Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

IMPORTANT : Please HARDCODE the data inside the code NO PROMPT please!!! The Pro

ID: 3720664 • Letter: I

Question

IMPORTANT : Please HARDCODE the data inside the code NO PROMPT please!!! The Process Scheduler relies on a scheduling algorithm, based on a specific scheduling policy, to allocate the CPU in the best way to move jobs through the system efficiently. Write a Java program that will simulate the following process scheduling algorithm: 1. First-Come, First-Served (FCFS) Your Java program should produce tables to presents computed results for each scheduling algorithm as shown in the following sample data for the validation your program’s computed results for each scheduling algorithm.

A) Timeline for First-Come First-Served (FCFS) algorithm: 12 15 18 20 Arrival CPU Start Finish Time Cycle Time Time Turnaround Time Finish Time Arrival Time Job 17-0=7 12 15 18 12 12-1 = 11 15 15-2 13 18 18 3 15 20 20-4 = 16 2 Average Turnaround Time (711 1315 16)/5 62/5 12.4

Explanation / Answer

import java.io.*;

class FCFS {

public static void main(String args[]) throws Exception {

int n = 5, at[] = { 0, 1, 2, 3, 4 }, bt[] = { 7, 5, 3, 3, 2 }, wt[], tat[],st[];

float awt = 0;

InputStreamReader isr = new InputStreamReader(System.in);

BufferedReader br = new BufferedReader(isr);

wt = new int[n];

tat = new int[n];

st=new int[n];

st[0]=0;

for(int i=1;i<n;i++)

{

st[i]=st[i-1]+bt[i-1];

}

wt[0] = 0;

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

wt[i] = st[i]-at[i];

}

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

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

}

System.out.println("PROCESS BURST-TIME WAITING-TIME TURN AROUND-TIME ");

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

System.out.println(" " + i + " " + bt[i] + " " + wt[i] + " " + tat[i]);

}

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

{

awt=awt+tat[i];

}

awt=awt/n;

System.out.println(" ");

System.out.println("Avg waiting time=" + awt + " ");

}

}