Copy the code code as follows:
package com;
import java.util.Arrays;
public class sjf {
public static void main(String[] args) {
sjf SJF=new sjf();
SJF.fun1();
}
int starttime;
int arrivetime;
int finishtime;
int zhouzhuan;
public void fun1(){
int a[]={1,3,2};
int c[]=new int[3];
for (int i = 0; i < 3; i++) {
c[i]=a[i];
}
Arrays.sort(c);
finishtime=a[0];
int[]d={0,3,3};
int zhouzhuan=finishtime-arrivetime;
float weightzhouzhuan=(float)zhouzhuan/a[0];//The weight turnover time is the turnover time h
System.out.println("Start time"+starttime+"/t"+"Arrival time"
+arrivetime+"/t"+"Completion time"+finishtime+"/t"+"Turnaround time"+zhouzhuan+"/t"+"Service time"+a[0]+"/t"+"With right turnaround time" +weightzhouzhuan);
for (int i = 1; i < 3; i++) {
arrivetime=d[i];
if(finishtime>=arrivetime){
starttime=finishtime;
finishtime+=c[i];
zhouzhuan=finishtime-arrivetime;
weightzhouzhuan=(float)zhouzhuan/c[i];
System.out.println("Start time"+starttime+"/t"+"Arrival time"
+arrivetime+"/t"+"completion time"+finishtime+"/t"+"turnaround time"+zhouzhuan+"/t"+"service time"+c[i]+"/t"+"right turnaround time" +weightzhouzhuan);
}else{
Arrays.sort(c);
starttime=arrivetime;
finishtime=starttime+c[i];
zhouzhuan=finishtime-arrivetime;
weightzhouzhuan=(float)zhouzhuan/c[i];
System.out.println("Start time"+starttime+"/t"+"Arrival time"
+arrivetime+"/t"+"completion time"+finishtime+"/t"+"turnaround time"+zhouzhuan+"/t"+"service time"+c[i]+"/t"+"right turnaround time" +weightzhouzhuan);
}
}
}
}