MPR (1) Merged
MPR (1) Merged
MPR (1) Merged
MPR PRESENTATION
Develop a Java GUI Program to
Process 'N' Jobs through two machines
sequencing problem
INTRODUCTION
Step 2:-
The smallest processing time between the two
machines is 2 which corresponds to task A on
machine.
Thus, task A is scheduled as early as possible to
give the sequence as shown below
Johnson’s Algorithm:
Step 3:-
The minimum processing time in this reduced problem is 3 which corresponds to task
E and G both on machine II. Since the corresponding time of task E on machine I is
less than corresponding time of task G on machine I, therefore, task E will be
scheduled in the last and task G shall be scheduled before it. Tasks E and G will not
be considered further. thus , current partial sequence of scheduling tasks becomes
The program prompts the user for the number of jobs and their
respective processing times on two machines.
import java.awt.*;
import java.awt.event.*;
import java.util.Arrays;
import java.util.Comparator;
public SimpleJobSequencingGUI() {
setSize(300, 300);
setLayout(new BorderLayout());
addWindowListener(new WindowAdapter() {
System.exit(0);
});
inputPanel.add(numJobsField);
calculateButton.addActionListener(this);
inputPanel.add(calculateButton);
resultArea.setEditable(false);
add(inputPanel, BorderLayout.NORTH);
add(resultArea, BorderLayout.CENTER);
@Override
try {
int[][] jobs = new int[numJobs][3]; // jobs[i][0] -> job number, jobs[i][1] -> Machine 1 time,
jobs[i][2] -> Machine 2 time
jobs[i][1] = Integer.parseInt(m1);
jobs[i][2] = Integer.parseInt(m2);
sequence[front++] = job[0];
} else {
sequence[back--] = job[0];
return sequence;
}
// Method to show input dialog
dialog.setLayout(new FlowLayout());
dialog.add(new Label(message));
dialog.add(inputField);
okButton.addActionListener(event -> {
dialog.setVisible(false);
});
dialog.add(okButton);
dialog.setSize(200, 100);
dialog.setVisible(true);
return inputField.getText();
errorDialog.setLayout(new FlowLayout());
errorDialog.add(new Label(message));
okButton.addActionListener(event -> {
errorDialog.setVisible(false);
});
errorDialog.add(okButton);
errorDialog.setSize(200, 100);
errorDialog.setVisible(true);
gui.setVisible(true);
OUTPUT: