P. 1
SCAN DISK SCHEDULING

SCAN DISK SCHEDULING

|Views: 2,494|Likes:
Published by esquivelazzej
DOWLOAD HERE: http://adf.ly/aJUZa
SCREENSHOT: http://www.mediafire.com/download/03e5veomcd91r4z/Scan.bmp.jpg
======
CSCI10

copy in notepad. save as Scan.java
DOWLOAD HERE: http://adf.ly/aJUZa
SCREENSHOT: http://www.mediafire.com/download/03e5veomcd91r4z/Scan.bmp.jpg
======
CSCI10

copy in notepad. save as Scan.java

More info:

Categories:Types, School Work
Published by: esquivelazzej on Dec 28, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
See more
See less

12/05/2013

DISK SCHEDULING: SCAN

import java.io.*; public class Scan { public static void main(String[]args) throws IOException{ BufferedReader br=new BufferedReader (new InputStreamReader(System.in)); int a,x,c,h,i,hm=0,temp; int anarray[]=new int[30]; System.out.print("\n\n Program name: SCAN\n\n");

System.out.print("\nEnter number of process: "); a=Integer.parseInt(br.readLine()); System.out.print("Initial head movement: "); h=Integer.parseInt(br.readLine()); System.out.print("\n"); anarray[0]=0; for (c=1;c<=a;c++){ System.out.print("Request #"+c+": "); anarray[c]=Integer.parseInt(br.readLine()); } anarray[c]=h; for(c=0;c<a+1;c++){ for(i=0;i<a-c+1;i++){ if (anarray[i]>anarray[i+1]){ temp=anarray[i]; anarray[i]=anarray[i+1]; anarray[i+1]=temp; } } } for(c=0;c<a+1;c++){ x=anarray[c+1]-anarray[c]; hm=hm+x; if(anarray[c]==h){ hm=hm-x; hm=hm+anarray[c+1]; } else; } System.out.println("\nTotal Head Movement: "+hm); } }

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->