Why i can't compile this code??

Ok..this is too long so i will devide the code..
can anyone help me to made it right?
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
#include <iostream>
#include <conio.h>
#include <vector>
#include <stdlib.h>
#include <fstream>

using namespace std;
ofstream output("C:\\Gantt_Chart.txt");

typedef vector<int> processInTimes;
vector <processInTimes> inTimes;
vector <int> processNumber,priority,ganttChart,arrivalTime;
vector <int> burstTime,waitingTime,turnaroundTime,startTime,finishTime;
int maxTime,btSum=0,choice=8;;
float waitingTimeAVG=0,turnaroundTimeAVG=0;

void printDetails();
void ganttChartPrint(int);
void ganttChartPrintPreemptive(int);
void print();
void sort(int);
void menu();
void option();
//Algorithms:
void FCFS();
void SJF();
void SRTF();
void nonPreemptivePriority();
void preemptivePriority();
void RR();

/**************** Main ***************/
int main()
{

	btSum=waitingTimeAVG=turnaroundTimeAVG=0;

	processNumber.clear();
	priority.clear();
	ganttChart.clear();
	arrivalTime.clear();
	burstTime.clear();
	waitingTime.clear();
	turnaroundTime.clear();
	startTime.clear();
	finishTime.clear();
	inTimes.clear();

	vector<int> tempVec;

	int read;

	ifstream input ("proc.txt");

	if (!input)
	{
		cerr<<"Error; cannot find \"proc.txt\"\nExiting..."<<endl;
		getch();
		exit(1);
		
	}

	while(!input.eof())
	{
		input>>read;
		processNumber.push_back(int(read));
		input>>read;
		burstTime.push_back(read);
		input>>read;
		arrivalTime.push_back(read);
		input>>read;
		priority.push_back(int(read));
		startTime.push_back(-1);
		finishTime.push_back(-1);
		waitingTime.push_back(-1);
		turnaroundTime.push_back(-1);
	}

	input.close();

	for (int y=0;y<processNumber.size()-1;y++)
	{
		btSum+=burstTime[y];
		inTimes.push_back(tempVec);
	}

	char key;
	menu();
	for (;;)
	{
		key=getch();
		if (key=='\r')
		{
			option();
			cout<<"Press any key..."<<endl;
			getch();
			main();
		}
		switch(key)
		{
		case 'H':
			if (choice<9)
				choice=15;
			else
				choice--;
			menu();break;

		case 'P':
			if (choice>14)
				choice=8;
			else
				choice++;
			menu();break;
		}
	}
	return 0;
}
/************** End Main *****************/


/***************** FCFS ******************/
void FCFS()
{

	vector<int> pn,pr;
	vector<int> bt,at;
	int inCPU=-1;
	bool isIdle;
	int sum1=0,sum2=0;

	cout<<"\n First Come First Serve (FCFS):"<<endl;
	cout<<" ------------------------------\n"<<endl;

	for (int j=0;j<processNumber.size();j++)
		for (int i=0;i<processNumber.size()-2;i++)
			if (arrivalTime[i]>arrivalTime[i+1])
				sort(i);

	for (int i=0;i<processNumber.size()-1;i++)
	{
		pn.push_back(processNumber[i]);
		pr.push_back(priority[i]);
		bt.push_back(burstTime[i]);
		at.push_back(arrivalTime[i]);
	}


	for (int time=0;time<=btSum;time++)
	{
		if (time==0)
			isIdle=true;
		if (inCPU!=-1 && time==(startTime[inCPU]+bt[inCPU]))
		{
				isIdle=true;
				finishTime[inCPU]=time;
				pn[inCPU]=-1;
		}
		for (i=0;i<processNumber.size()-1;i++)
			if (pn[i]!=-1 && at[i]<=time && isIdle)
			{
				ganttChart.push_back(pn[i]);
				startTime[i]=time;
				isIdle=false;
				inCPU=i;
			}//end search if.
	}//end time.
	maxTime=time;

	for (j=0;j<processNumber.size();j++)
		for (i=0;i<processNumber.size()-2;i++)
			if (processNumber[i]>processNumber[i+1])
				sort(i);

	for (i=0;i<processNumber.size()-1;i++)
	{
		waitingTime[i]=startTime[i]-arrivalTime[i];
		sum1+=waitingTime[i];
		turnaroundTime[i]=waitingTime[i]+burstTime[i];
		sum2+=turnaroundTime[i];
	}
	
	waitingTimeAVG=float(sum1)/(waitingTime.size()-1);
	turnaroundTimeAVG=float(sum2)/(turnaroundTime.size()-1);

	print();
	cout<<"\nPaused..."<<endl;
	getch();
	ganttChartPrint(1);
}
/******************** End FCFS ***********************/


/******************** SJF ****************************/
void SJF()
{
	vector<int> pn,pr;
	vector<int> bt,at;
	int inCPU=-1;
	bool isIdle;
	int sum1=0,sum2=0;

	cout<<"\n Shortest Job First (SJF):"<<endl;
	cout<<" -------------------------\n"<<endl;

	for (int j=0;j<processNumber.size();j++)
		for (int i=0;i<processNumber.size()-2;i++)
		{
			if (burstTime[i]==burstTime[i+1])
				if (arrivalTime[i]>arrivalTime[i+1])
					sort(i);
			if (burstTime[i]>burstTime[i+1])
				sort(i);
		}
for (int i=0;i<processNumber.size()-1;i++)
	{
		pn.push_back(processNumber[i]);
		pr.push_back(priority[i]);
		bt.push_back(burstTime[i]);
		at.push_back(arrivalTime[i]);
	}

	for (int time=0;time<=btSum;time++)
	{
		if (time==0)
			isIdle=true;
		if (inCPU!=-1 && time==startTime[inCPU]+burstTime[inCPU])
		{
			finishTime[inCPU]=time;
			isIdle=true;
		}
		for (i=0;i<processNumber.size()-1;i++)
			if (pn[i]!=-1 && at[i]<=time && isIdle)
			{
				ganttChart.push_back(pn[i]);
				startTime[i]=time;
				pn[i]=-1;
				inCPU=i;
				isIdle=false;
			}
	}

	maxTime=time;

	for (j=0;j<processNumber.size();j++)
		for (i=0;i<processNumber.size()-2;i++)
			if (processNumber[i]>processNumber[i+1])
				sort(i);

	for (i=0;i<processNumber.size()-1;i++)
	{
		waitingTime[i]=startTime[i]-arrivalTime[i];
		sum1+=waitingTime[i];
		turnaroundTime[i]=waitingTime[i]+burstTime[i];
		sum2+=turnaroundTime[i];
	}

	waitingTimeAVG=float(sum1)/(waitingTime.size()-1);
	turnaroundTimeAVG=float(sum2)/(turnaroundTime.size()-1);

	print();
	cout<<"\nPaued..."<<endl;
	getch();
	ganttChartPrint(2);
}
/****************** End SJF **************************/


/********************** SRTF *************************/
void SRTF()
{
	vector<int> pn,pr;
	vector<int> bt,at,timeRemaining;
	int inCPU;
	int sum1=0,sum2=0;

	cout<<"\n Shortest Remaining Time First (SRTF):"<<endl;
	cout<<" -------------------------------------\n"<<endl;


	for (int j=0;j<processNumber.size();j++)
		for (int i=0;i<processNumber.size()-2;i++)
		{
			if (burstTime[i]==burstTime[i+1])
				if (arrivalTime[i]>arrivalTime[i+1])
					sort(i);
			if (burstTime[i]>burstTime[i+1])
				sort(i);
		}

	for (int i=0;i<processNumber.size()-1;i++)
	{
		pn.push_back(processNumber[i]);
		pr.push_back(priority[i]);
		bt.push_back(burstTime[i]);
		at.push_back(arrivalTime[i]);
		timeRemaining.push_back(burstTime[i]);
	}
	timeRemaining.push_back(btSum);
	inCPU=timeRemaining.size()-1;

	for (int time=0;time<=btSum;time++)
	{
		for (i=0;i<processNumber.size()-1;i++)
		{
			if (pn[i]!=-1 && at[i]<=time && bt[i]<=timeRemaining[inCPU])
			{
				ganttChart.push_back(pn[i]);
				inTimes[i].push_back(time);
				inCPU=i;
			}
		}

		timeRemaining[inCPU]--;
		if (timeRemaining[inCPU]==0)
		{
			finishTime[inCPU]=time+1;
			pn[inCPU]=-1;
			inCPU=timeRemaining.size()-1;
		}
	}
this the 2nd part
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
maxTime=time;

	for (j=0;j<processNumber.size();j++)
		for (i=0;i<processNumber.size()-2;i++)
			if (processNumber[i]>processNumber[i+1])
				sort(i);

	for (i=0;i<processNumber.size()-1;i++)
	{
		waitingTime[i]=finishTime[i]-burstTime[i]-arrivalTime[i];
		sum1+=waitingTime[i];
		turnaroundTime[i]=waitingTime[i]+burstTime[i];
		sum2+=turnaroundTime[i];
	}

	waitingTimeAVG=float(sum1)/(waitingTime.size()-1);
	turnaroundTimeAVG=float(sum2)/(turnaroundTime.size()-1);

	print();
	cout<<"\nPaued..."<<endl;
	getch();
	ganttChartPrintPreemptive(1);

}
/******************** End SRTF ***********************/


/***************** NON-PRE-PRIOR *********************/
void nonPreemptivePriority()
{
	vector<int> pn,pr;
	vector<int> bt,at;
	int inCPU=-1;
	bool isIdle;
	int sum1=0,sum2=0;

	cout<<"\n Non-Preemptive Priority:"<<endl;
	cout<<" ------------------------\n"<<endl;

	for (int j=0;j<processNumber.size();j++)
		for (int i=0;i<processNumber.size()-2;i++)
		{
			if (priority[i]==priority[i+1])
				if (arrivalTime[i]>arrivalTime[i+1])
					sort(i);
			if (priority[i]>priority[i+1])
				sort(i);
		}

	for (int i=0;i<processNumber.size()-1;i++)
	{
		pn.push_back(processNumber[i]);
		pr.push_back(priority[i]);
		bt.push_back(burstTime[i]);
		at.push_back(arrivalTime[i]);
	}

	pr.push_back(1000);
	inCPU=pr.size()-1;

	for (int time=0;time<=btSum;time++)
	{
		if (time==0)
			isIdle=true;
		if (inCPU!=-1 && time==(startTime[inCPU]+bt[inCPU]))
		{
				isIdle=true;
				finishTime[inCPU]=time;
				pn[inCPU]=-1;
				inCPU=pr.size()-1;
		}
		for (i=0;i<processNumber.size()-1;i++)
			if (pn[i]!=-1 && pr[i]<pr[inCPU] && at[i]<=time && isIdle)
			{
				ganttChart.push_back(pn[i]);
				startTime[i]=time;
				isIdle=false;
				inCPU=i;
			}//end search if.
	}//end time.
	maxTime=time;

	for (j=0;j<processNumber.size();j++)
		for (i=0;i<processNumber.size()-2;i++)
			if (processNumber[i]>processNumber[i+1])
				sort(i);

	for (i=0;i<processNumber.size()-1;i++)
	{
		waitingTime[i]=startTime[i]-arrivalTime[i];
		sum1+=waitingTime[i];
		turnaroundTime[i]=waitingTime[i]+burstTime[i];
		sum2+=turnaroundTime[i];
	}
	
	waitingTimeAVG=float(sum1)/(waitingTime.size()-1);
	turnaroundTimeAVG=float(sum2)/(turnaroundTime.size()-1);

	print();
	cout<<"\nPaused..."<<endl;
	getch();
	ganttChartPrint(3);

}

/*************** End NON-PRE-PRIOR *******************/


/******************** PRE-PRIOR **********************/
void preemptivePriority()
{
	vector<int> pn,pr;
	vector<int> bt,at,timeRemaining;
	int inCPU;
	int sum1=0,sum2=0;

	cout<<"\n Preemptive Priority:"<<endl;
	cout<<" --------------------\n"<<endl;

	for (int j=0;j<processNumber.size();j++)
		for (int i=0;i<processNumber.size()-2;i++)
		{
			if (priority[i]==priority[i+1])
				if (arrivalTime[i]>arrivalTime[i+1])
					sort(i);
			if (priority[i]>priority[i+1])
				sort(i);
		}

	for (int i=0;i<processNumber.size()-1;i++)
	{
		pn.push_back(processNumber[i]);
		pr.push_back(priority[i]);
		bt.push_back(burstTime[i]);
		at.push_back(arrivalTime[i]);
		timeRemaining.push_back(burstTime[i]);
	}
	pr.push_back(1000);
	inCPU=pr.size()-1;

	for (int time=0;time<=btSum;time++)
	{
		for (i=0;i<processNumber.size()-1;i++)
		{
			if (pn[i]!=-1 && at[i]<=time && pr[i]<pr[inCPU])
			{
				ganttChart.push_back(pn[i]);
				inTimes[i].push_back(time);
				inCPU=i;
			}
		}

		timeRemaining[inCPU]--;
		if (timeRemaining[inCPU]==0)
		{
			finishTime[inCPU]=time+1;
			pn[inCPU]=-1;
			inCPU=pr.size()-1;
		}
	}

	maxTime=time;

	for (j=0;j<processNumber.size();j++)
		for (i=0;i<processNumber.size()-2;i++)
			if (processNumber[i]>processNumber[i+1])
				sort(i);


	for (i=0;i<processNumber.size()-1;i++)
	{
		waitingTime[i]=finishTime[i]-burstTime[i]-arrivalTime[i];
		sum1+=waitingTime[i];
		turnaroundTime[i]=waitingTime[i]+burstTime[i];
		sum2+=turnaroundTime[i];
	}

	waitingTimeAVG=float(sum1)/(waitingTime.size()-1);
	turnaroundTimeAVG=float(sum2)/(turnaroundTime.size()-1);

	print();
	cout<<"\nPaued..."<<endl;
	getch();
	ganttChartPrintPreemptive(2);

}
/***************** End PRE-PRIOR *********************/


/********************** RR ***************************/
void RR()
{
	cout<<"RR is not ready yet!"<<endl;
}
/******************** End RR *************************/


/**************** Print  Details *********************/
void printDetails()
{
	cout<<"\n\n\t\tProcesses Information"<<endl;
	cout<<"\t\t---------------------\n"<<endl;
	cout<<" Process#\tCPU Time\tArrival Time\tPriority"<<endl;
	cout<<" --------\t--------\t------------\t--------"<<endl;
	for (int i=0;i<processNumber.size()-1;i++)
	{
		cout<<"     "<<processNumber[i]<<"\t\t  "
		<<burstTime[i]<<"\t\t   "
		<<arrivalTime[i]<<"\t\t"
		<<"   "<<priority[i]<<endl;
	}
	cout<<endl;

}
/**************** End Print  Details ****************/


/*************** Gantt char print ******************/
void ganttChartPrint(int a)
{

	bool printed=false;
	vector<bool> prints;

	for (int l=0;l<=maxTime;l++)
		prints.push_back(false);

	cout<<"\nGantt Chart order:\n------>\n"<<endl;
	cout<<"     "<<char(218);
	for (int h=0;h<22;h++)
		cout<<char(196);
	cout<<char(191)<<endl;
	cout<<char(218)<<char(196)<<char(196)<<char(196)<<char(196)<<char(180)
		<<" First procss in CPU. "<<char(179)<<endl;
	cout<<char(179)<<"    "<<char(192);
	for (h=0;h<22;h++)
		cout<<char(196);
	cout<<char(217)<<endl<<char(179)<<endl;
	cout<<char(192)<<char(196)<<char(196)<<"> ";
	for (int i=0;i<ganttChart.size();i++)
		if (i!=ganttChart.size()-1)
			cout<<"P("<<ganttChart[i]<<") then ";
		else
			cout<<"P("<<ganttChart[i]<<")";
	cout<<endl<<endl;
	cout<<"\t\t"<<char(218);
	for (int y=0;y<48;y++)
		cout<<char(196);
	cout<<char(191)<<endl;
	cout<<"\t\t"<<char(179)<<" Note: To view the Gantt chart goto drive (C:\\) "<<char(179)<<endl
		<<"\t\t"<<char(179)<<" and open a text file named \"Gantt_Chart.txt\".  "<<char(179)<<endl;
	cout<<"\t\t"<<char(192);
	for (y=0;y<48;y++)
		cout<<char(196);
	cout<<char(217)<<endl<<endl;

	//to Gantt_Chart.txt
	output<<endl;

	output<<"Gantt Chart for ";
	if (a==1)
		output<<"First Come First Serve (FCFS):"<<endl;
	if (a==2)
		output<<"Shortest Job First (SJF):"<<endl;
	if (a==3)
		output<<"Non-Preemptive Priority:"<<endl;
	output<<endl<<"\t";

	for (i=0;i<maxTime-1;i++)
		output<<"___";
	output<<"_"<<endl<<"\t";

		

	for (int time=0;time<maxTime;time++)
	{
		for (i=0;i<ganttChart.size();i++)
		{
		
			if (startTime[i]==time)
			{
				if (processNumber[i]<10)
					output<<"|P"<<processNumber[i];
				else
					output<<"|"<<processNumber[i];
				printed=true;
				prints[time]=true;
			}
		}
		for (i=0;i<ganttChart.size();i++)
		{
			if (finishTime[i]==time && prints[time]==false )
			{
				output<<"|  ";
				printed=true;
			}
		}
		if (!printed)
			output<<"   ";
		printed=false;
	}

	output<<endl<<"\t";
	for (i=0;i<maxTime;i++)
		output<<"___";
	output<<endl<<"\t";

	for (i=0;i<maxTime;i++)
		output<<"|  ";
	output<<endl<<"\t";

	for (i=0;i<maxTime;i++)
		if (i<10)
			output<<i<<"  ";
		else if (i<100)
			output<<i<<" ";
		else
			output<<i;
	output<<endl<<endl;


}
/************ End Gantt Char Print ***************/


/********* Gantt Char Print Preemptive ***********/
void ganttChartPrintPreemptive(int a)
{
	bool printed=false;
	vector<bool> prints;

	for (int l=0;l<=maxTime;l++)
		prints.push_back(false);
and this is the 3rd part..
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
cout<<"\nGantt Chart order:\n------>\n"<<endl;
	cout<<"     "<<char(218);
	for (int h=0;h<22;h++)
		cout<<char(196);
	cout<<char(191)<<endl;
	cout<<char(218)<<char(196)<<char(196)<<char(196)<<char(196)<<char(180)
		<<" First procss in CPU. "<<char(179)<<endl;
	cout<<char(179)<<"    "<<char(192);
	for (h=0;h<22;h++)
		cout<<char(196);
	cout<<char(217)<<endl<<char(179)<<endl;
	cout<<char(192)<<char(196)<<char(196)<<"> ";
	for (int i=0;i<ganttChart.size();i++)
		if (i!=ganttChart.size()-1)
			cout<<"P("<<ganttChart[i]<<") then ";
		else
			cout<<"P("<<ganttChart[i]<<")";
	cout<<endl<<endl;
	cout<<"\t\t"<<char(218);
	for (int y=0;y<48;y++)
		cout<<char(196);
	cout<<char(191)<<endl;
	cout<<"\t\t"<<char(179)<<" Note: To view the Gantt chart goto drive (C:\\) "<<char(179)<<endl
		<<"\t\t"<<char(179)<<" and open a text file named \"Gantt_Chart.txt\".  "<<char(179)<<endl;
	cout<<"\t\t"<<char(192);
	for (y=0;y<48;y++)
		cout<<char(196);
	cout<<char(217)<<endl<<endl;

	//to Gantt_Chart.txt
	
	output<<endl;

	output<<"Gantt Chart for ";
	if (a==1)
		output<<"Shortest Remaining Time First (SRTF):"<<endl;
	if (a==2)
		output<<"Preemptive Priority:"<<endl;
	if (a==3)
		output<<"Round Robin (RR):"<<endl;
	output<<endl<<"\t";

	for (i=0;i<maxTime-1;i++)
		output<<"___";
	output<<"_"<<endl<<"\t";

		

	for (int time=0;time<maxTime;time++)
	{
		for (i=0;i<inTimes.size();i++)
		{
			for (int j=0;j<inTimes[i].size();j++)
			{
				if (inTimes[i][j]==time)
				{
					if (processNumber[i]<10)
						output<<"|P"<<processNumber[i];
					else
						output<<"|"<<processNumber[i];
					printed=true;
					prints[time]=true;
				}
			}
		}	
		for (i=0;i<ganttChart.size();i++)
		{
			if (finishTime[i]==time && prints[time]==false )
			{
				output<<"|  ";
				printed=true;
			}
		}
		if (!printed)
			output<<"   ";
		printed=false;
	}

	output<<endl<<"\t";
	for (i=0;i<maxTime;i++)
		output<<"___";
	output<<endl<<"\t";

	for (i=0;i<maxTime;i++)
		output<<"|  ";
	output<<endl<<"\t";

	for (i=0;i<maxTime;i++)
		if (i<10)
			output<<i<<"  ";
		else if (i<100)
			output<<i<<" ";
		else
			output<<i;
	output<<endl<<endl;

}
/******* End Gantt Char Print Preemptive *********/


/****************** Print ***********************/
void print()
{
	cout<<"P#\tstart Time\tfinish time\tWaiting Time\tTurnaround Time"<<endl;
	cout<<"--\t----------\t-----------\t------------\t---------------"<<endl;
	for (int i=0;i<processNumber.size()-1;i++)
	{
		cout<<processNumber[i]<<"\t   ";
		if (startTime[i]==-1)
			cout<<"u/a"<<"\t\t";
		else
			cout<<startTime[i]<<"\t\t   ";
		cout<<finishTime[i]
		<<"\t\t   "<<waitingTime[i]<<"\t\t   "<<turnaroundTime[i]<<endl;
	}
	cout<<endl;
	cout<<"Waiting time average: "<<waitingTimeAVG<<endl;
	cout<<"Turnaround time average: "<<turnaroundTimeAVG<<endl;
}
/***************** End Print *****************/


/***************** Sort *********************/
void sort(int i)
{
	int temp;
	vector<int> vecTemp;

	temp=processNumber[i];
	processNumber[i]=processNumber[i+1];
	processNumber[i+1]=temp;

	temp=burstTime[i];
	burstTime[i]=burstTime[i+1];
	burstTime[i+1]=temp;

	temp=arrivalTime[i];
	arrivalTime[i]=arrivalTime[i+1];
	arrivalTime[i+1]=temp;

	temp=priority[i];
	priority[i]=priority[i+1];
	priority[i+1]=temp;

	temp=startTime[i];
	startTime[i]=startTime[i+1];
	startTime[i+1]=temp;

	temp=finishTime[i];
	finishTime[i]=finishTime[i+1];
	finishTime[i+1]=temp;

	vecTemp=inTimes[i];
	inTimes[i]=inTimes[i+1];
	inTimes[i+1]=vecTemp;


}
/****************** End Sort *******************/


/******************** Menu *********************/
void menu()
{
	system("cls");
	cout<<"\n\n\t\tMain Menu"<<endl;
	cout<<"\t\t---------\n"<<endl;
	if (choice==8)
		cout<<" "<<char(196)<<char(26)<<" View processes information."<<endl;
	else
		cout<<"    View processes information."<<endl;
	if (choice==9)
		cout<<" "<<char(196)<<char(26)<<" First Come first Serve (FCFS)."<<endl;
	else
		cout<<"    First Come first Serve (FCFS)."<<endl;
	if (choice==10)
		cout<<" "<<char(196)<<char(26)<<" Shortest Job First (SJF)."<<endl;
	else
		cout<<"    Shortest Job First (SJF)."<<endl;
	if (choice==11)
		cout<<" "<<char(196)<<char(26)<<" Shortest Remaining Time First (SRTF)."<<endl;
	else
		cout<<"    Shortest Remaining Time First (SRTF)."<<endl;
    if (choice==12)
		cout<<" "<<char(196)<<char(26)<<" Non Preemptive Priority."<<endl;
	else
		cout<<"    Non Preemptive Priority."<<endl;
	if (choice==13)
		cout<<" "<<char(196)<<char(26)<<" Preemptive Priority."<<endl;
	else
		cout<<"    Preemptive Priority."<<endl;
	if (choice==14)
		cout<<" "<<char(196)<<char(26)<<" Round Robin (RR)."<<endl;
	else
		cout<<"    Round Robin (RR)."<<endl;
	if (choice==15)
		cout<<" "<<char(196)<<char(26)<<" Exit."<<endl;
	else
		cout<<"    Exit."<<endl;

	cout<<"\n\n  "<<char(218);
	for (int s=0;s<57;s++)
		cout<<char(196);
	cout<<char(191)<<endl;
	cout<<"  "<<char(179)<<" Note: Use the arrow keys ("
		<<char(24)<<","<<char(25)<<") to choose from the menu. "<<char(179)<<endl;
	cout<<"  "<<char(192);
	for (s=0;s<57;s++)
		cout<<char(196);
	cout<<char(217)<<endl;

}
/****************** End Menu *******************/


/******************* Option ********************/
void option()
{
	system("cls");
	if (choice==8) printDetails();
	else if (choice==9)	FCFS();
	else if (choice==10) SJF();
	else if (choice==11) SRTF();
	else if (choice==12) nonPreemptivePriority();
	else if (choice==13) preemptivePriority();
	else if (choice==14) RR();
	else if (choice==15)
	{
		cout<<"\n\n\n\n\n\n\n\n\n\t\t\t\tOsama Farah"<<endl;
		cout<<"\t\t\t\t 200410677"<<endl;
		cout<<" Exiting..."<<endl;
		getch();
		exit(0);
	}

}
/***************** End Option ******************/
Ok. This is soooo long(as you said), and it will scare most people from helping. What I am trying to say is, at least show as the errors it's giving you, in order to make work easier for us.
Last edited on
Topic archived. No new replies allowed.