0% found this document useful (0 votes)
41 views4 pages

String C New String (4) Int A New Int (4) Int B New Int

The document contains code for a Java program that performs job scheduling operations. It defines arrays to store job details like names, durations and calculates metrics like waiting time, turnaround time. It then implements bubble sort to sort the jobs by duration. Finally it calculates and displays metrics like average waiting time and average turnaround time.

Uploaded by

Dayanara Cuevas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views4 pages

String C New String (4) Int A New Int (4) Int B New Int

The document contains code for a Java program that performs job scheduling operations. It defines arrays to store job details like names, durations and calculates metrics like waiting time, turnaround time. It then implements bubble sort to sort the jobs by duration. Finally it calculates and displays metrics like average waiting time and average turnaround time.

Uploaded by

Dayanara Cuevas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

private void PROCEEDActionPerformed(java.awt.event.

ActionEvent evt) {

String[] c = new String[4]; c[1] = P2.getText();

int[] a = new int[4]; c[2] = P3.getText();

int[] b = new int[4]; c[3] = P4.getText();

a[1] = Integer.parseInt(A2.getText());
int[] OP = new int[4];
a[2] = Integer.parseInt(A3.getText());
int[] WT = new int[4];
a[3] = Integer.parseInt(A4.getText());
int[] TAT = new int[4];
b[1] = Integer.parseInt(B2.getText());

b[2] = Integer.parseInt(B3.getText());
OP[0] = 1;
b[3] = Integer.parseInt(B4.getText());
OP[1] = 2;

OP[2] = 3;
for(int i=0; i < n; i++){
OP[3] = 4;
for(int j=1; j < (n-i); j++){

if(b[j-1] > b[j]){

int n = b.length;

int temp1 = 0;
// temp1 = b[j-1];
int temp2 = 0;
b[j-1] = b[j];
String temp3 = "";
b[j] = temp1;
int temp4 = 0;
// temp2 = a[j-1];

a[j-1] = a[j];

a[j] = temp2;

// temp3 = c[j-1];

c[j-1] = c[j];

c[j] = temp3;

// temp4 = OP[j-1];

OP[j-1] = OP[j];

OP[j] = temp4;

}
//G1.setText(P1.getText());

G2.setText(c[1]); for(int i=0; i < n; i++){

G3.setText(c[2]); for(int j=1; j < (n-i); j++){

G4.setText(c[3]); if(OP[j-1] > OP[j]){

// GC1.setText("0"); // temp1 = OP[j-1];

GC2.setText(B1.getText()); OP[j-1] = OP[j];

GC3.setText(String.valueOf(Integer.parseInt(GC2.getText()) + b[1])); OP[j] = temp1;

GC4.setText(String.valueOf(Integer.parseInt(GC3.getText()) + b[2])); // temp2 = WT[j-1];

GC5.setText(String.valueOf(Integer.parseInt(GC4.getText()) + b[3])); WT[j-1] = WT[j];

//WT[0] = Integer.parseInt(GC1.getText()); WT[j] = temp2;

WT[1] = Integer.parseInt(GC2.getText()); // temp4 = TAT[j-1];

WT[2] = Integer.parseInt(GC3.getText()); TAT[j-1] = TAT[j];

WT[3] = Integer.parseInt(GC4.getText()); TAT[j] = temp4;

WT[0] = Integer.parseInt(GC2.getText()); }

WT[1] = Integer.parseInt(GC3.getText()); }

WT[2] = Integer.parseInt(GC4.getText()); }

WT[3] = Integer.parseInt(GC5.getText());

W1.setText("0");

W2.setText(String.valueOf(Integer.parseInt(GC2.getText())-a[1]));

if(Integer.parseInt(W2.getText())<0){

W2.setText("0");

W3.setText(String.valueOf(Integer.parseInt(GC3.getText())-a[2]));

if(Integer.parseInt(W3.getText())<0){

W3.setText("0");

W4.setText(String.valueOf(Integer.parseInt(GC4.getText())-a[3]));

if(Integer.parseInt(W4.getText())<0){

W4.setText("0");

int sum;

double average;

sum = Integer.parseInt(W1.getText())+Integer.parseInt(W2.getText())+Integer.parseInt(W3.getText())+Integer.parseInt(W4.getText());

average = sum / 4.0;

AWT.setText(String.valueOf(average));
TT1.setText(String.valueOf(Integer.parseInt(GC2.getText())-Integer.parseInt(GC1.getText())+Integer.parseInt(W1.getText())));

if(Integer.parseInt(TT1.getText())<0){

TT1.setText("0");

TT2.setText(String.valueOf(Integer.parseInt(GC3.getText())-Integer.parseInt(GC2.getText())+Integer.parseInt(W2.getText())));

if(Integer.parseInt(TT1.getText())<0){

TT2.setText("0");

TT3.setText(String.valueOf(Integer.parseInt(GC4.getText())-Integer.parseInt(GC3.getText())+Integer.parseInt(W3.getText())));

if(Integer.parseInt(TT1.getText())<0){

TT3.setText("0");

TT4.setText(String.valueOf(Integer.parseInt(GC5.getText())-Integer.parseInt(GC4.getText())+Integer.parseInt(W4.getText())));

if(Integer.parseInt(TT1.getText())<0){

TT4.setText("0");

sum = Integer.parseInt(TT1.getText())+Integer.parseInt(TT2.getText())+Integer.parseInt(TT3.getText())
+Integer.parseInt(TT4.getText());

average = sum/4.0;

ATT.setText(String.valueOf(average));

private void CLEARActionPerformed(java.awt.event.ActionEvent evt) {

for (Component c : jPanel1.getComponents())

if (c instanceof JTextField)

JTextField x = (JTextField)c;

x.setText("");

You might also like