Please help My code is not working

The program compiles with no error but i don t get the correct output.
[code]
// Header file for Cpu scheduling
#ifndef cpuh_h
#define cpuh_h
#include<iostream>
#include<conio.h>
#include<stdio.h>
class cpuschedule
{
int n, Bu[20];
float Twt, Awt, A[10], Wt[10], w;
public:
//Getting the No of processes & burst time
void Getdata();
//First come First served Algorithm
void Fcfs();
//Shortest job First Algorithm
void Sjf();
//Shortest job First Algorithm with Preemption
void SjfP();
//Shortest job First Algorithm with NonPreemption
void SjfNp();
//Round Robin Algorithm
void RoundRobin();
//Priority Algorithm
void Priority();
};
#endif

#include"cpuh.h"
//Getting no of processes and Burst time
using namespace std;
void cpuschedule::Getdata()
{

int i;
cout << "Enter the no of processes:" << endl;
cin >> n;
for (i = 1; i <= n; i++)
{
cout << "Enter The BurstTime for Process p" << i << "= " << endl;
cin >> Bu[i];
}
}
//First come First served Algorithm
void cpuschedule::Fcfs()
{
int i, B[10];
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "= " ;
cout << B[i];
}
Wt[1] = 0;
for (i = 2; i <= n; i++)
{
Wt[i] = B[i - 1] + Wt[i - 1];
}
//Calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm
void cpuschedule::Sjf()
{
int i, j, temp, B[10];
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "= " << endl;
cout << B[i];
}
for (i = n; i >= 1; i--)
{
for (j = 1; j <= n; j++)
{
if (B[j - 1]>B[j])
{
temp = B[j - 1];
B[j - 1] = B[j];
B[j] = temp;
}
}
}
Wt[1] = 0;
for (i = 2; i <= n; i++)
{
Wt[i] = B[i - 1] + Wt[i - 1];
}
//calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm with NonPreemption
void cpuschedule::SjfNp()
{
int i, B[10], Tt = 0, temp, j;
char S[10];
float A[10], temp1, t;
Twt = 0.0;
w = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "= " << endl;
cout << B[i] << endl;
S[i] = 'T';
Tt = Tt + B[i];
cout << "Enter the Arrival Time for" << i << "th process= " << endl;
cin >> A[i];
}
for (i = n; i >= 1; i--)
{
for (j = 3; j <= n; j++)
{
if (B[j - 1]>B[j])
{
temp = B[j - 1];
temp1 = A[j - 1];
B[j - 1] = B[j];
A[j - 1] = A[j];
B[j] = temp;
A[j] = temp1;
}
}
}
for (i = 1; i <= n; i++)
{
cout << "p" << i << " " << B[i] << " " << A[i];
}
//For the 1st process
Wt[1] = 0;
w = w + B[1];
t = w;
S[1] = 'F';
while (w<Tt)
{
i = 2;
while (i <= n)
{
if (S[i] == 'T'&&A[i] <= t)
{
Wt[i] = w;
cout << "WT" << i << "=" << Wt[i] << endl;
S[i] = 'F';
w = w + B[i];
t = w;
i = 2;
}
else
i++;
}
}
for (i = 1; i <= n; i++)
cout << "Wt" << i << "==" << Wt[i] << endl;
//calculating average weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + (Wt[i] - A[i]);
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << "" << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Priority Algorithm
void cpuschedule::Priority()
{
int i, B[10], P[10], j;
w = 0.0;
int max;
Twt = 0.0;
max = 1;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "= " << endl;
cout << B[i] << endl;
cout << "Enter the priority for process P" << i << "= " << endl;
cin >> P[i];
if (max<P[i])
max = P[i];
}
j = 1;
while (j <= max)
{
i = 1;
while (i <= n)
{
if (P[i] == j)
{
Wt[i] = w;
w = w + B[i];
}
i++;
}
j++;
}
//calculating average weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << "" << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm with Preemption
void cpuschedule::SjfP()
{
int i, j, m, Wt[10], k, B[10], A[10], Tt = 0, Wtm[10], temp;
char S[20], start[20];
int max = 0, Time = 0, min;
float Twt = 0.0, Awt;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process P" << i << "= " << B[i] << endl;
if (B[i]>max)
max = B[i];
Wt[i] = 0;
S[i] = 'T';
start[i] = 'F';
Tt = Tt + B[i];
cout << "Enter the Arrival Time for" << i << "th process= " << endl;
cin >> A[i];
if (A[i]>Time)
Time = A[i];
}
//cout<<"Max="<<max;
int w = 0, flag = 0, t = 0;
i = 1;
while (t<Time)
{
if (A[i] <= t && B[i] != 0)
{
if (flag == 0)
{
Wt[i] = Wt[i] + w;
cout << "Wt[" << i << "]=" << Wt[i] << endl;
}
B[i] = B[i] - 1;
if (B[i] == 0)
S[i] = 'F';
start[i] = 'T';
t++;
w = w + 1;
if (S[i] != 'F')
{
j = 1; flag = 1;
while (j <= n && flag != 0)
{
if (S[j] != 'F' && B[i]>B[j] && A[j] <= t && i != j)
{
flag = 0;
Wt[i] = Wt[i] - w;
i = j;
}
else
{
flag = 1;
}
j++;
}
}
else
{
i++;
j = 1;
while (A[j] <= t &&j <= n)
{
if (B[i]>B[j] && S[j] != 'F')
{
flag = 0;
i = j;
}
j++;
}
}
}
else
if (flag == 0)
i++;
}
cout << "Printing remaining burst time" << endl;
for (i = 1; i <= n; i++)
cout << "B[" << i << "]=" << B[i] << endl;
cout << "" << endl;
while (w<Tt)
{
min = max + 1;
i = 1;
while (i <= n)
{
if (min>B[i] && S[i] == 'T')
{
min = B[i];
j = i;
}
i++;
}
i = j;
if (w == Time && start[i] == 'T')
{
w = w + B[i];
S[i] = 'F';
}
else
{
Wt[i] = Wt[i] + w;
w = w + B[i];
S[i] = 'F';
}
}
cout << "Weight info" << endl;
for (i = 1; i <= n; i++)
cout << "WT[" << i << "]=" << Wt[i] << endl;
cout << "after subtracting arrival time" << endl;
for (i = 1; i <= n; i++)
{
Wt[i] = Wt[i] - A[i];
cout << "WT[" << i << "]=" << Wt[i] << endl;
}
//Calculating Average Weighting time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Average Weighting Time=" << Awt << endl;
}
//Round Robin Algorithm
void cpuschedule::RoundRobin()
{
int i, j, tq, k, B[10], Rrobin[10][10], count[10];
int max = 0;
int m;
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "= ";
cout << B[i];
if (max<B[i])
max = B[i];
Wt[i] = 0;
}
cout << "Enter the Time Quantum=" << endl;
cin >> tq;
//TO find the dimension of the Rrobin array
m = max / tq + 1;
//initializing Rrobin array
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
Rrobin[i][j] = 0;
}
}
//placing value in the Rrobin array
i = 1;
while (i <= n)
{
j = 1;
while (B[i]>0)
{
if (B[i] >= tq)
{
B[i] = B[i] - tq;
Rrobin[i][j] = tq;
j++;
}
else
{
Rrobin[i][j] = B[i];
B[i] = 0;
j++;
}
}
count[i] = j - 1;
i++;
}
cout << "Display";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
cout << "Rr[" << i << "," << j << "]=" << Rrobin[i][j] << endl;
cout << " ";
}
cout << "" << endl;
}
//calculating weighting time
int x = 1;
i = 1;
while (x <= n)
{
for (int a = 1; a<x; a++)
{
Wt[x] = Wt[x] + Rrobin[a][i];
}
i = 1;
int z = x;
j = count[z];
k = 1;
while (k <= j - 1)
{
if (i == n + 1)
{
i = 1;
k++;
}
else
{
if (i != z)
{
Wt[z] = Wt[z] + Rrobin[i][k];
}
i++;
}
}
x++;
}
for (i = 1; i <= n; i++)
cout << "Weighting Time for process P" << i << "=" << Wt[i] << endl;
//calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Application file for cpu Scheduling
#include "cpuh.h"
using namespace std;
void main()
{

int ch, cho;
cpuschedule c;
do
{
cout << " MENU" <<endl;
cout << "1.Getting BurstTime" << endl;
cout << "2.FirstComeFirstServed" << endl;
cout << "3.ShortestJobFirst" << endl;
cout << "4.RoundRobin" << endl;
cout << "5.Priority" << endl;
cout << "6.EXIT" << endl;
cout << "Enter your choice" << endl;
cin >> ch;
switch (ch)
{
case 1:
c.Getdata();
break;
case 2:
cout << "FIRST COME FIRST SERVED SCHEDULING" << endl;
c.Fcfs();
break;
case 3:
cout << "SHORTEST JOB FIRST SCHEDULING" << endl;
do
{
cout << "1.SJF-Normel" << endl;
cout << "2.SJF-Preemptive" << endl;
cout << "3.SJF-NonPreemptive" << endl;
cout << "Enter your choice" << endl;
cin >> cho;
switch (cho)
{
case 1:
c.Sjf();
break;
case 2:
c.SjfP();
break;
case 3:
c.SjfNp();
break;
}
} while (cho <= 3);
break;
case 4:
cout << "ROUND ROBIN SCHEDULING" << endl;
c.RoundRobin();
break;
case 5:
cout << "PRIORITY SCHEDULING" << endl;
c.Priority();
break;
case 6:
break;
}
} while (ch <= 5);
}
Simulation By considering the following set of processes with the length of the CPU-burst time given in milliseconds:
Process Burst Time Priority
-------- ------------ ---------
P1 9 3
P2 1 1
P3 2 3
P4 1 4
P5 5 2
Simulating the execution of these processes to users.
Last edited on
Please use code tags when posting code, to make it readable:

http://www.cplusplus.com/articles/z13hAqkS/
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
// Header file for Cpu scheduling
#ifndef cpuh_h
#define cpuh_h
#include<iostream>
#include<conio.h>
#include<stdio.h>
class cpuschedule
{
int n, Bu[20];
float Twt, Awt, A[10], Wt[10], w;
public:
//Getting the No of processes & burst time
void Getdata();
//First come First served Algorithm
void Fcfs();
//Shortest job First Algorithm
void Sjf();
//Shortest job First Algorithm with Preemption
void SjfP();
//Shortest job First Algorithm with NonPreemption
void SjfNp();
//Round Robin Algorithm
void RoundRobin();
//Priority Algorithm
void Priority();
};}

#endif
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
#include"cpuh.h"
//Getting no of processes and Burst time
using namespace std;
void cpuschedule::Getdata()
{

int i;
cout << "Enter the no of processes:" << endl;
cin >> n;
for (i = 1; i <= n; i++)
{
cout << "Enter The BurstTime for Process p" << i << "=	" << endl;
cin >> Bu[i];
}
}
//First come First served Algorithm
void cpuschedule::Fcfs()
{
int i, B[10];
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "=	" ;
cout << B[i];
}
Wt[1] = 0;
for (i = 2; i <= n; i++)
{
Wt[i] = B[i - 1] + Wt[i - 1];
}
//Calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm
void cpuschedule::Sjf()
{
int i, j, temp, B[10];
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "=	" << endl;
cout << B[i];
}
for (i = n; i >= 1; i--)
{
for (j = 1; j <= n; j++)
{
if (B[j - 1]>B[j])
{
temp = B[j - 1];
B[j - 1] = B[j];
B[j] = temp;
}
}
}
Wt[1] = 0;
for (i = 2; i <= n; i++)
{
Wt[i] = B[i - 1] + Wt[i - 1];
}
//calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm with NonPreemption
void cpuschedule::SjfNp()
{
int i, B[10], Tt = 0, temp, j;
char S[10];
float A[10], temp1, t;
Twt = 0.0;
w = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "=	" << endl;
cout << B[i] << endl;
S[i] = 'T';
Tt = Tt + B[i];
cout << "Enter the Arrival Time for" << i << "th process=	" << endl;
cin >> A[i];
}
for (i = n; i >= 1; i--)
{
for (j = 3; j <= n; j++)
{
if (B[j - 1]>B[j])
{
temp = B[j - 1];
temp1 = A[j - 1];
B[j - 1] = B[j];
A[j - 1] = A[j];
B[j] = temp;
A[j] = temp1;
}
}
}
for (i = 1; i <= n; i++)
{
cout << "p" << i << "	" << B[i] << "	" << A[i];
}
//For the 1st process
Wt[1] = 0;
w = w + B[1];
t = w;
S[1] = 'F';
while (w<Tt)
{
i = 2;
while (i <= n)
{
if (S[i] == 'T'&&A[i] <= t)
{
Wt[i] = w;
cout << "WT" << i << "=" << Wt[i] << endl;
S[i] = 'F';
w = w + B[i];
t = w;
i = 2;
}
else
i++;
}
}
for (i = 1; i <= n; i++)
cout << "Wt" << i << "==" << Wt[i] << endl;
//calculating average weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + (Wt[i] - A[i]);
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << "" << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Priority Algorithm
void cpuschedule::Priority()
{
int i, B[10], P[10], j;
w = 0.0;
int max;
Twt = 0.0;
max = 1;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "=	" << endl;
cout << B[i] << endl;
cout << "Enter the priority for process P" << i << "=	" << endl;
cin >> P[i];
if (max<P[i])
max = P[i];
}
j = 1;
while (j <= max)
{
i = 1;
while (i <= n)
{
if (P[i] == j)
{
Wt[i] = w;
w = w + B[i];
}
i++;
}
j++;
}
//calculating average weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << "" << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Shortest job First Algorithm with Preemption
void cpuschedule::SjfP()
{
int i, j, m, Wt[10], k, B[10], A[10], Tt = 0, Wtm[10], temp;
char S[20], start[20];
int max = 0, Time = 0, min;
float Twt = 0.0, Awt;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process P" << i << "=	" << B[i] << endl;
if (B[i]>max)
max = B[i];
Wt[i] = 0;
S[i] = 'T';
start[i] = 'F';
Tt = Tt + B[i];
cout << "Enter the Arrival Time for" << i << "th process=	" << endl;
cin >> A[i];
if (A[i]>Time)
Time = A[i];
}
//cout<<"Max="<<max;
int w = 0, flag = 0, t = 0;
i = 1;
while (t<Time)
{
if (A[i] <= t && B[i] != 0)
{
if (flag == 0)
{
Wt[i] = Wt[i] + w;
cout << "Wt[" << i << "]=" << Wt[i] << endl;
}
B[i] = B[i] - 1;
if (B[i] == 0)
S[i] = 'F';
start[i] = 'T';
t++;
w = w + 1;
if (S[i] != 'F')
{
j = 1; flag = 1;
while (j <= n && flag != 0)
{
if (S[j] != 'F' && B[i]>B[j] && A[j] <= t && i != j)
{
flag = 0;
Wt[i] = Wt[i] - w;
i = j;
}
else
{
flag = 1;
}
j++;
}
}
else
{
i++;
j = 1;
while (A[j] <= t &&j <= n)
{
if (B[i]>B[j] && S[j] != 'F')
{
flag = 0;
i = j;
}
j++;
}
}
}
else
if (flag == 0)
i++;
}
cout << "Printing remaining burst time" << endl;
for (i = 1; i <= n; i++)
cout << "B[" << i << "]=" << B[i] << endl;
cout << "" << endl;
while (w<Tt)
{
min = max + 1;
i = 1;
while (i <= n)
{
if (min>B[i] && S[i] == 'T')
{
min = B[i];
j = i;
}
i++;
}
i = j;
if (w == Time && start[i] == 'T')
{
w = w + B[i];
S[i] = 'F';
}
else
{
Wt[i] = Wt[i] + w;
w = w + B[i];
S[i] = 'F';
}
}
cout << "Weight info" << endl;
for (i = 1; i <= n; i++)
cout << "WT[" << i << "]=" << Wt[i] << endl;
cout << "after subtracting arrival time" << endl;
for (i = 1; i <= n; i++)
{
Wt[i] = Wt[i] - A[i];
cout << "WT[" << i << "]=" << Wt[i] << endl;
}
//Calculating Average Weighting time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Average Weighting Time=" << Awt << endl;
}
//Round Robin Algorithm
void cpuschedule::RoundRobin()
{
int i, j, tq, k, B[10], Rrobin[10][10], count[10];
int max = 0;
int m;
Twt = 0.0;
for (i = 1; i <= n; i++)
{
B[i] = Bu[i];
cout << "Burst time for process p" << i << "=	";
cout << B[i];
if (max<B[i])
max = B[i];
Wt[i] = 0;
}
cout << "Enter the Time Quantum=" << endl;
cin >> tq;
//TO find the dimension of the Rrobin array
m = max / tq + 1;
//initializing Rrobin array
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
Rrobin[i][j] = 0;
}
}
//placing value in the Rrobin array
i = 1;
while (i <= n)
{
j = 1;
while (B[i]>0)
{
if (B[i] >= tq)
{
B[i] = B[i] - tq;
Rrobin[i][j] = tq;
j++;
}
else
{
Rrobin[i][j] = B[i];
B[i] = 0;
j++;
}
}
count[i] = j - 1;
i++;
}
cout << "Display";
for (i = 1; i <= n; i++)
{
for (j = 1; j <= m; j++)
{
cout << "Rr[" << i << "," << j << "]=" << Rrobin[i][j] << endl;
cout << "	";
}
cout << "" << endl;
}
//calculating weighting time
int x = 1;
i = 1;
while (x <= n)
{
for (int a = 1; a<x; a++)
{
Wt[x] = Wt[x] + Rrobin[a][i];
}
i = 1;
int z = x;
j = count[z];
k = 1;
while (k <= j - 1)
{
if (i == n + 1)
{
i = 1;
k++;
}
else
{
if (i != z)
{
Wt[z] = Wt[z] + Rrobin[i][k];
}
i++;
}
}
x++;
}
for (i = 1; i <= n; i++)
cout << "Weighting Time for process P" << i << "=" << Wt[i] << endl;
//calculating Average Weighting Time
for (i = 1; i <= n; i++)
Twt = Twt + Wt[i];
Awt = Twt / n;
cout << "Total Weighting Time=" << Twt << endl;
cout << "Average Weighting Time=" << Awt << "" << endl;
}
//Application file for cpu Scheduling
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
#include "cpuh.h"
using namespace std;
void main()
{

int ch, cho;
cpuschedule c;
do
{
cout << "	MENU" <<endl;
cout << "1.Getting BurstTime" << endl;
cout << "2.FirstComeFirstServed" << endl;
cout << "3.ShortestJobFirst" << endl;
cout << "4.RoundRobin" << endl;
cout << "5.Priority" << endl;
cout << "6.EXIT" << endl;
cout << "Enter your choice" << endl;
cin >> ch;
switch (ch)
{
case 1:
c.Getdata();
break;
case 2:
cout << "FIRST COME FIRST SERVED SCHEDULING" << endl;
c.Fcfs();
break;
case 3:
cout << "SHORTEST JOB FIRST SCHEDULING" << endl;
do
{
cout << "1.SJF-Normel" << endl;
cout << "2.SJF-Preemptive" << endl;
cout << "3.SJF-NonPreemptive" << endl;
cout << "Enter your choice" << endl;
cin >> cho;
switch (cho)
{
case 1:
c.Sjf();
break;
case 2:
c.SjfP();
break;
case 3:
c.SjfNp();
break;
}
} while (cho <= 3);
break;
case 4:
cout << "ROUND ROBIN SCHEDULING" << endl;
c.RoundRobin();
break;
case 5:
cout << "PRIORITY SCHEDULING" << endl;
c.Priority();
break;
case 6:
break;
}
} while (ch <= 5);
}
Topic archived. No new replies allowed.