Hi programmers i need to have a GUI code for
4 cpu scheduling algorithms OR AT LEAST THE THREE, W/O
THE ROUND ROBIN..

can you help me

interface(menu):
Cpu scheduling algorithms
1.FCFS
2.SJF
3.PRIORITY
4.ROUND ROBIN
CHOICE:______
NOTE:5 DEFAULT PROCESSES ARE GIVEN.

PLEASE HELP..THANKS!

Are you asking for where to look for the code you need?
Have you tried Google?

Or can you hire a java programmer to write it for you?

Are you asking for where to look for the code you need?
Have you tried Google?

Or can you hire a java programmer to write it for you?

yes..or maybe someone who knows the codes for this program

yes..or maybe someone who knows the codes for this program

No one is going to give you the code unless you show some code of your own; more specifically, what have you done so far?

you are totally right NormR1..hey gabz by the way this scheduling techniques are more simple than you can ever think believe me especially first come first serve and shortest job first so if you couldn't catch them well you can google 'it

Thanks for the idea guys..
Here is my code so far..

Note: I need to have the sjf as preemptive it means with arrival time
for each process..plz help..

import java.util.*;
import javax.swing.*;



public class CpuScheduling1
{


    public static void main(String[ ]args)
    {


            int m=Integer.parseInt(JOptionPane.showInputDialog( "                Menu\n[1]First- Come First-Served\n[2]Shortest Job First\n[3]Priority\n\nEnter Choice:"));


            if (m==1)
            {
                    FCFS();
            }
            else if (m==2)
            {
                    SJF();
            }
            else if (m==3)
            {
                    P();
            }
            else
            {
                    JOptionPane.showMessageDialog(null,"Error Message","Error!",JOptionPane.ERROR_MESSAGE);
            }
    }

    public static void FCFS()
    {
            int bp[]=new int[5],wtp[] =new int[5],twt=0, awt,num;
    String output1[]=new String[10];



            for (num=0;num<=4;num++)
            {
                    bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));

            }

            for (num=0;num<=4;num++)
            {
                    if (num==0)
                    {
                            wtp[num]=0;

                    }
                    else
                    {
                            wtp[num]=wtp[ num-1]+bp[ num-1];
                            output1[num]="\nWaiting time for P"+(num+1)+" = "+wtp[num];
                    }


            }


            for (num=0;num<=4;num++)
            {
                    twt=twt+wtp[ num];
            }
    awt=twt/5;


            JOptionPane.showMessageDialog(null,output1,"FCFS",JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null,"\nAverage Waiting Time =" + awt,"FCFS",JOptionPane.INFORMATION_MESSAGE);

    }

    public static void SJF()
    {
            int bp[]=new int[5],wtp[] =new int[5],twt=0, awt,x,num, temp=0,p[ ]=new int[5];
            boolean found=false;

            for (num=0;num<=4;num++)
            {
                    bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));

            }

            for (num=0;num<=4;num++)
            {
                    p[num]=bp[num] ;
            }

            for (x=0;x<=3;x++)
            {
                    for (num=0;num<=3;num++)
                    {
                            if (p[num]>p[num+1])
                            {
                                    temp=p[num];
                                    p[num]=p[num+ 1];
                                    p[num+1]=temp;
                            }
                    }
            }

            for (num=0;num<=4;num++)
            {
                    if (num==0)
                    {
                            for (x=0;x<=4;x++)
                            {

                                    if (p[num]==bp[ x] && found==false)
                                    {
                                            wtp[num]=0;
                                           JOptionPane.showMessageDialog(null, "\nWaiting time for P"+(x+1)+" = "+wtp[num]);
                                            bp[x]=0;
                                            found=true;
                                    }

                            }
                            found=false;
                    }
                    else
                    {
                            for (x=0;x<=4;x++)
                            {

                                    if (p[num]==bp[ x] && found==false)
                                    {
                                            wtp[num]=wtp[ num-1]+p[ num-1];
                                            JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
                                            bp[x]=0;
                                            found=true;
                                    }

                            }
                            found=false;
                    }
            }

            for (num=0;num<=4;num++)
            {
                    twt=twt+wtp[ num];
            }

          JOptionPane.showMessageDialog(null,"\n\nAverage waiting time: "+(awt=twt/5) );


    }

    public static void P()
    {
            int bp[]=new int[5],wtp[] =new int[6],p[]=new int[5],sp[]= new int[5],twt=0, awt,num,x, temp=0;
            boolean found=false;

            for (num=0;num<=4;num++)
            {
                    bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));

            }

            for (num=0;num<=4;num++)
            {
                   p[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Priority for P"+(num+1)+" : "));

            }

            for (num=0;num<=4;num++)
            {
                    sp[num]=p[num] ;
            }

            for (x=0;x<=3;x++)
            {
                    for (num=0;num<=3;num++)
                    {
                            if (sp[num]>sp[num+1])
                            {
                                    temp=sp[num] ;
                                    sp[num]=sp[num+ 1];
                                    sp[num+1]=temp;
                            }
                    }
            }

            for (num=0;num<=4;num++)
            {
                    if (num==0)
                    {
                            for (x=0;x<=4;x++)
                            {

                                    if (sp[num]==p[ x] && found==false)
                                    {
                                            wtp[num]=0;
                                          JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
                                            temp=x;
                                            p[x]=0;
                                            found=true;
                                    }

                            }
                            found=false;
                    }
                    else
                    {
                            for (x=0;x<=4;x++)
                            {

                                    if (sp[num]==p[ x] && found==false)
                                    {

                                            wtp[num]=wtp[ num-1]+bp[ temp];
                                            JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
                                            temp=x;
                                            p[x]=0;
                                            found=true;
                                    }

                            }
                            found=false;
                    }
            }

            for (num=0;num<=4;num++)
            {
                    twt=twt+wtp[ num];
            }

            JOptionPane.showMessageDialog(null,"\n\nAverage waiting time: "+(awt=twt/5) );


    }
}

Please edit your posted code and add code tags. Unformatted code is hard to read.

Also add some comments describing the logic of the program so others can know what it is the code is supposed to do. If the code is doing what it is supposed to do, then leave them off.

Program Logic:
If the user presses "1"
the program will prompt the user for 5 burst times,
then the program will solve for the fcfs,display
the waiting time for each process and the average waiting time.

Almost same flow as the sjf and the priority.

Note: I need to have the sjf as pre-emptive it means that
it prompts the user for 5 burst time and 5 arrival times,
solve for the waiting time for each process and display the
average waiting time.

Please edit your posted code and add code tags. Unformatted code is hard to read.

I agree with normR1, I really found difficulty to know each attribute and what it means in your program, so it will be helpful if you do what normR1 asked you if you need some one to help you.....

Here is your code in the forum's code tag...

I think you should combine all the parts where you ask for bursting time of each thread instead of separate them all... Make the code lengthy... By the way, you could do the tick with 1 time unit each until all processes are completed.

Oh, where is the arriving time for each process? You will need that in waiting time computation.

import java.util.*;
import javax.swing.*;

public class CpuScheduling1 {
  public static void main(String[ ]args) {
    int m=Integer.parseInt(JOptionPane.showInputDialog( " Menu\n[1]First- Come First-Served\n[2]Shortest Job First\n[3]Priority\n\nEnter Choice:"));

    if (m==1) {
      FCFS();
    }
    else if (m==2) {
      SJF();
    }
    else if (m==3) {
      P();
    }
    else {
      JOptionPane.showMessageDialog(null,"Error Message","Error!",JOptionPane.ERROR_MESSAGE);
    }
  }

  public static void FCFS() {
    int bp[]=new int[5],wtp[] =new int[5],twt=0, awt,num;
    String output1[]=new String[10];

    for (num=0;num<=4;num++) {
      bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));
    }

    for (num=0;num<=4;num++) {
      if (num==0) {
        wtp[num]=0;
      }
      else {
        wtp[num]=wtp[ num-1]+bp[ num-1];
        output1[num]="\nWaiting time for P"+(num+1)+" = "+wtp[num];
      }
    }

    for (num=0;num<=4;num++) {
      twt=twt+wtp[ num];
    }
    awt=twt/5;

    JOptionPane.showMessageDialog(null,output1,"FCFS",JOptionPane.INFORMATION_MESSAGE);
    JOptionPane.showMessageDialog(null,"\nAverage Waiting Time =" + awt,"FCFS",JOptionPane.INFORMATION_MESSAGE);
  }

  public static void SJF() {
    int bp[]=new int[5],wtp[] =new int[5],twt=0, awt,x,num, temp=0,p[ ]=new int[5];
    boolean found=false;

    for (num=0;num<=4;num++) {
      bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));
    }

    for (num=0;num<=4;num++) {
      p[num]=bp[num] ;
    }

    for (x=0;x<=3;x++) {
      for (num=0;num<=3;num++) {
        if (p[num]>p[num+1]) {
          temp=p[num];
          p[num]=p[num+ 1];
          p[num+1]=temp;
        }
      }
    }

    for (num=0;num<=4;num++) {
      if (num==0) {
        for (x=0;x<=4;x++) {
          if (p[num]==bp[ x] && found==false) {
            wtp[num]=0;
            JOptionPane.showMessageDialog(null, "\nWaiting time for P"+(x+1)+" = "+wtp[num]);
            bp[x]=0;
            found=true;
          }
        }
        found=false;
      }
      else {
        for (x=0;x<=4;x++) {
          if (p[num]==bp[ x] && found==false) {
            wtp[num]=wtp[ num-1]+p[ num-1];
            JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
            bp[x]=0;
            found=true;
          }
        }
        found=false;
      }
    }
    for (num=0;num<=4;num++) {
      twt=twt+wtp[ num];
    }
    JOptionPane.showMessageDialog(null,"\n\nAverage waiting time: "+(awt=twt/5) );
  }

  public static void P() {
    int bp[]=new int[5],wtp[] =new int[6],p[]=new int[5],sp[]= new int[5],twt=0, awt,num,x, temp=0;
boolean found=false;

    for (num=0;num<=4;num++) {
      bp[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Burst time for P"+(num+1)+" : "));
    }

    for (num=0;num<=4;num++) {
      p[num]=Integer.parseInt(JOptionPane.showInputDialog( "\nEnter Priority for P"+(num+1)+" : "));
    }

    for (num=0;num<=4;num++) {
      sp[num]=p[num];
    }

    for (x=0;x<=3;x++) {
      for (num=0;num<=3;num++) {
        if (sp[num]>sp[num+1]) {
          temp=sp[num];
          sp[num]=sp[num+ 1];
          sp[num+1]=temp;
        }
      }
    }

    for (num=0;num<=4;num++) {
      if (num==0) {
        for (x=0;x<=4;x++) {
          if (sp[num]==p[ x] && found==false) {
            wtp[num]=0;
            JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
            temp=x;
            p[x]=0;
            found=true;
          }
        }
        found=false;
      }
      else {
        for (x=0;x<=4;x++) {
          if (sp[num]==p[ x] && found==false) {
            wtp[num]=wtp[ num-1]+bp[ temp];
            JOptionPane.showMessageDialog(null,"\nWaiting time for P"+(x+1)+" = "+wtp[num]);
            temp=x;
            p[x]=0;
            found=true;
          }
        }
        found=false;
      }
    }
    for (num=0;num<=4;num++) {
      twt=twt+wtp[ num];
    }

    JOptionPane.showMessageDialog(null,"\n\nAverage waiting time: "+(awt=twt/5) );
  }
}

Hi :))

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

class FCFS11  extends JFrame implements ActionListener
{
   JButton jb[] = new JButton[3];
   JTextField  jt1[],jt2[];
   JLabel  jl[],jl1,jl2,jl3;
   JPanel  jp,jp1,jp2;
   Container con;
   int  k,p;
   String str[] = {"SUBMIT","BACK","EXIT"};
   String str1[] = {"Job","   AT","BT","WT","ET","TAT","   NTAT"};


   public FCFS11()
        {
       super("FCFS scheduling algorithm");
           con = getContentPane();

           k= Integer.parseInt(JOptionPane.showInputDialog("Enter number of job"));

           jl1 = new JLabel("\t      Job");
           jl2 = new JLabel("Arrival Time");
           jl3 = new JLabel("Burst Time");

           jl = new JLabel[k];
           jt1 = new JTextField[k];
           jt2 = new JTextField[k];


       for(int i=0;i<k;i++)
           {
                   jl[i] = new JLabel("      Job "+(i+1));
                   jt1[i]  = new JTextField(10);
                   jt2[i]  = new JTextField(10);
           }

          for(int i=0;i<3;i++)
          {
                  jb[i] = new JButton(str[i]);
          }

          con.setLayout(new  GridLayout(k+2,3));
          con.add(jl1);
          con.add(jl2);
          con.add(jl3);

          int l=0;

                for(int i=0;i<k;i++)
                {
                        con.add(jl[l]);
                        con.add(jt1[l]);
                        con.add(jt2[l]);
                        l++;
                }
          l=0;
                for(int i=0;i<3;i++)
                {
                  con.add(jb[l]);
                  jb[l].addActionListener(this);
                  l++;
                }
        }//end of constructor

        public void actionPerformed(ActionEvent ae)
        {
                int FT[] = new int[k];
                int WT[] = new int[k];
                int TAT[] = new int[k];
        float NTAT[] = new float[k];
                float sum=0;
                float sum2=0;
        float avg;
        float avg2;
                 JPanel main = new JPanel();
                 main.setLayout(new BorderLayout());
                 jp = new JPanel();
                 jp1 = new JPanel();
                 jp2 = new JPanel();
                 jp.setLayout(new GridLayout(k+1,7));
                 jp1.setLayout(new FlowLayout());
                 jp2.setLayout(new FlowLayout());


                if(ae.getSource() == jb[2])
                  {
                        System.exit(0);
                  }
                else if(ae.getSource() == jb[0])
                  {
                  FT[0] = Integer.parseInt(jt1[0].getText()) + Integer.parseInt(jt2[0].getText());

                  for(int i=0;i<k;i++)
                        {
                          if(i==0)
                                 WT[i] = 0;
                           else
                             {
                                  if(FT[i-1] < Integer.parseInt(jt1[i].getText()))
                                        {
                                          FT[i] =Integer.parseInt(jt1[i].getText())+Integer.parseInt(jt2[i].getText());
                                          WT[i] = 0;
                                        }
                                        else
                                        {
                                                FT[i] = FT[i-1] + Integer.parseInt(jt2[i].getText());
                                                WT[i] = FT[i-1] - Integer.parseInt(jt1[i].getText());
                                        }

                }
                                TAT[i] = WT[i]+Integer.parseInt(jt2[i].getText());
                                NTAT[i] = TAT[i]/(Integer.parseInt(jt2[i].getText()));
                                sum = sum+WT[i];
                                sum2= sum2+FT[i];


                        }//end for loop
            for (int i=0;i<7;i++ )
            {
                          jp.add(new JLabel(str1[i]));
            }
                        for (int i=0;i<k;i++)
                        {
                          jp.add(new JLabel("Job "+(i+1)));
                          jp.add(new JLabel("   "+Integer.parseInt(jt1[i].getText())));
                          jp.add(new JLabel(""+Integer.parseInt(jt2[i].getText())));
                          jp.add(new JLabel(""+WT[i]));
                          jp.add(new JLabel(""+FT[i]));
                          jp.add(new JLabel(""+TAT[i]));
                          jp.add(new JLabel(""+NTAT[i]));


                        }
                        avg = sum/k;
                        avg2=sum2/k;
                        String str2 = "Average Waiting Time is "+ avg;
                        String str3 = "Average Turn-Around Time is "+ avg2;
                         jp1.add(new JLabel(str2));
                         jp2.add(new JLabel(str3));
                         main.add(jp,BorderLayout.NORTH);
                         main.add(jp1,BorderLayout.SOUTH);
                         main.add(jp2,BorderLayout.EAST);



JOptionPane.showMessageDialog(null,main,"Output",JOptionPane.PLAIN_MESSAGE
);

        }
                else if(ae.getSource() == jb[1])
                {
                        setVisible(false);
                        FCFS11  window = new FCFS11();
                        window.setSize(500,400);
                        window.setVisible(true);
                        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

                }
        }//END ACTION PERFORMED

        public static void main(String[] args)
        {
            FCFS11  window = new FCFS11();
                        window.setSize(400,300);
                        window.setVisible(true);
                        window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        }//end main
}//end class

leeana. This is a long dead thread.
DaniWeb Member Rules include:
"Do not hijack old threads by posting a new question as a reply to an old one"
http://www.daniweb.com/community/rules
Please start your own new thread for your question

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.