-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOSprojecttesing.java
More file actions
88 lines (83 loc) · 2.61 KB
/
OSprojecttesing.java
File metadata and controls
88 lines (83 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
package project;
import java.io.*;
public class OSprojecttesing extends osproject{
static void castFileIntoArrays(File file,String[] jobNames,int[] timeNeeded) throws IOException {
BufferedReader reader = new BufferedReader(new FileReader(file));
String str;
int line = 0;
int row = 0;
while((str = reader.readLine())!=null) {
if(line == 0) {
jobNames[row] = str;
line++;
}else {
timeNeeded[row]= Integer.parseInt(str);
line--;
row++;
}
}
reader.close();
}
public static void main(String args[]) throws IOException {
int count =0;
int count1=0;
int count2=0;
System.out.println("\ntestdata1.txt: ");
while(count<=4) {
String jobNumber[] = new String[6];
int jobtime[] = new int[6];
castFileIntoArrays(new File("C:\\Users\\liste\\Downloads\\testdata1.txt"), jobNumber, jobtime);
if(count==0) {
System.out.println("First Come First Serve:");
fcfs(jobNumber, jobtime);}
if(count==1) {
System.out.println("\nShortest job first: ");
shortestjobfirst(jobNumber, jobtime);}
if(count==2) {
System.out.println("\nRound Robin 2: ");
RR2(jobNumber, jobtime);}
if(count==3) {
System.out.println("\nRound Robin 5: ");
RR5(jobNumber, jobtime);}
count++;
}
System.out.println("\ntestdata2.txt: ");
while(count1<=4) {
String jobNumber[] = new String[10];
int jobtime[] = new int[10];
castFileIntoArrays(new File("C:\\Users\\liste\\Downloads\\testdata2.txt"), jobNumber, jobtime);
if(count1==0) {
System.out.println("First Come First Serve:");
fcfs(jobNumber, jobtime);}
if(count1==1) {
System.out.println("\nShortest job first: ");
shortestjobfirst(jobNumber, jobtime);}
if(count1==2) {
System.out.println("\nRound Robin 2: ");
RR2(jobNumber, jobtime);}
if(count1==3) {
System.out.println("\nRound Robin 5: ");
RR5(jobNumber, jobtime);}
count1++;
}
System.out.println("\ntestdata3.txt: ");
while(count2<=4) {
String jobNumber[] = new String[18];
int jobtime[] = new int[18];
castFileIntoArrays(new File("C:\\Users\\liste\\Downloads\\testdata3.txt"), jobNumber, jobtime);
if(count2==0) {
System.out.println("First Come First Serve:");
fcfs(jobNumber, jobtime);}
if(count2==1) {
System.out.println("\nShortest job first: ");
shortestjobfirst(jobNumber, jobtime);}
if(count2==2) {
System.out.println("\nRound Robin 2: ");
RR2(jobNumber, jobtime);}
if(count2==3) {
System.out.println("\nRound Robin 5: ");
RR5(jobNumber, jobtime);}
count2++;
}
}
}