Chans Assignment
Chans Assignment
Arrays;
import java.util.Scanner;
do {
menu(burst_time, no_p);
System.out.println("\nDo you want to continue ?\nPress -1 to exit. Or
else continue.");
String input = new Scanner(System.in).next();
if (input.equals("-1")) {
break;
}
}
while (true);
System.out.println("Input choice");
int n = in.nextInt();
switch (n) {
case 1 -> algorithmOne(bt, num);
case 2 -> algorithmTwo(bt, num);
case 3 -> algorithmThree(bt, num);
case 4 -> algorithmFour(bt, num);
default -> System.out.println("ERROR!! Choice should be between 1 and
4");
}
}
for(int i=0;i<number;i++)
{
TWT = TWT + WT[i];
}
}
System.out.println("\
n----------------------------------------------------------------");
System.out.println("\nAverage waiting time : "+avg_wait);
}
//Sorting
Arrays.sort(copy);
int[] p;
int[] pp;
int[] w;
int awt, TWT=0;
int temp = 0;
p = new int[number];
pp = new int[number];
w = new int[number];
for(int i=0;i<number;i++)
{
System.out.print("\nProcess["+(i+1)+"]:");
pp[i] = s.nextInt();
p[i]=i+1;
}
Arrays.sort(copy);
for(int i=0;i<number;i++) {
TAT[i] = WT[i] + a[i];
System.out.println("process\t\tBT\tWT\tTAT");
}
for(int i=0;i<number;i++)
{
System.out.println("process"+(i+1)+"\t"+a[i]+"\t"+WT[i]+"\t"+TAT[i]);
}
float avg_wt=0;
for(int j=0;j<number;j++)
{
avg_wt+=WT[j];
}