You are on page 1of 2

import java.awt.

Rectangle;
import java.util.Scanner;
public class Main_Scheduling {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int n, burst_time;
int process_burst[];
Scanner in = new Scanner(System.in);
System.out.println("Enter Total No. of processes");
n=Integer.parseInt(in.nextLine());
process_burst= new int[n];
for (int i=0; i<n; i++){
System.out.println("Enter Burst Timeof Process " + i);
burst_time = Integer.parseInt(in.nextLine());
process_burst[i]=burst_time;
}
System.out.println("Input of Burst Time for all processe
s done");
process_burst=selectionSort(process_burst);
Rectangle rect;
int prev_position=10;
System.out.println("\n\n\tGantt Chart\n");
System.out.print(" |");
for (int i=0; i<n; i++){
rect= new Rectangle (prev_position,10,process_burst[i]
,5);
for (int j=0; j<process_burst[i]; j++){
System.out.print("_");
}
System.out.print(" P" + i + "=" + process_burst[i] + "
__ |");
}
System.out.print(" \n\n");
}
public static int[] selectionSort(int[] data){
int lenD = data.length;
int j = 0;
int tmp = 0;
for(int i=0;i<lenD;i++){

j = i;
for(int k = i;k<lenD;k++){
if(data[j]>data[k]){
j = k;
}
}
tmp = data[i];
data[i] = data[j];
data[j] = tmp;
}
return data;
}
}

You might also like