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

Please only the LOOK algorithm not anything else. I have posted this question an

ID: 3573844 • Letter: P

Question

Please only the LOOK algorithm not anything else. I have posted this question and have received incorrect response.

Write a program that implements the following disk-scheduling algorithms in java:

LOOK please only the LOOK algorithm not anything else. I have posted this question and have received incorrect response.

Your program will service a disk with 5,000 cylinders numbered 0 to 4,999. The program will generate a random series of 1000 cylinder requests and service them according to each of the algorithms listed above. (The initial position of the disk head is random). Report the total amount of head movement required by each algorithm on average after 100 times experiments

Explanation / Answer

import java.util.*;
class fcfs_dsk
{
public static void main(String args[])
{
int n,i,hs,flag,total=0;
Scanner sc=new Scanner(System.in);
System.out.println(“Enter no of cylinders”);
n=sc.nextInt();
int c[]=new int[n];
int hm[]=new int[n];
System.out.println(“Enter the cylinder no.”);
for(i=0;i<n;i++)
c[i]=sc.nextInt();
System.out.println(“enter head start”);
hs=sc.nextInt();
flag=hs;
for(i=0;i<n;i++)
{
if(c[i] > flag)
hm[i]=c[i]-flag;
else
hm[i]=flag-c[i];
flag=c[i];
}
for(i=0;i<n;i++)
total=total+hm[i];
System.out.println(“The total no of cylinders traversed during disk movement is:”+ total);
}
}