FCFS (First Come First Serve)


FCFS (First Come First Serve) import java.util.*;
class Fcfs
{
int c=0,at[],bt[],wt=0,twt=0,tat=0,ttat=0,i,pid;
Scanner src=new Scanner(System.in);
void read()
{
System.out.println("enter the number of at,bt of process:"+i);
int at=src.nextInt();
int bt=src.nextInt();
}
void display()
{
pid=++c;
System.out.println(" pid \t  at \t bt n\t wt \t tat");
System.out.print(" "+pid +"\t "+ at+" \t"+ bt+" \t");
System.out.println(wt-at+" \t"+ wt+bt-at+"\t");
wt+=bt-at;
}
}
class Cfcfs
{
public static void main(String args[])
{
Scanner src=new Scanner(System.in);
Fcfs a=new Fcfs();
int ch;
do
{
System.out.println("1:read\n2:display\n3:exit \n enter ur choice");
ch=src.nextInt();
switch(ch)
{
case 1:
a.read();
break;
case 2:
a.display();
break;
case 3:
break;
}
}
while(ch!=3);
}
}


0 comments :