-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstrategyVal.cpp
210 lines (185 loc) · 4.88 KB
/
strategyVal.cpp
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
#include"strategyVal.h"
#include"rollno.h"
//#include"input.in"
void verification :: getInput()
{
inFile.open("rooms_detail.out");
inFile >> totalRoom;
for( i=0; i < totalRoom; i++)
{
inFile >> roomName[i] >> rows[i] >>cols[i];
}
inFile.close();
inFile.open("roll.in");
inFile >> totalBranches;
for(i=0; i< totalBranches; i++)
{
inFile >> branchCode[i] >> branchStudent[i];
for(j=0; j<branchStudent[i]; j++)
{
inFile >> subjectRoll[i][j];
}
cout<<"Rooms Detail: " <<totalBranches <<" " << subjectRoll[i][j] << " " <<branchCode[i] << " "<< branchStudent[i] <<"\n";
}
inFile.close();
}
// to select strategy
void verification :: methodSelection()
{
do
{
cout<<"Select Strategy and enter your choice\n"
/* <<"1. two group Strategy.Example:\n\tgroupA\tgroupA\tgroupA\n\tgroupB\tgroupB\tgroupB\n\tgroupA\tgroupA\tgroupA\n\t"
<<"groupB\tgroupB\tgroupB\n";
*/
<<"1. Four group Strategy.Example:\n\tgroupA\tgroupC\tgroupA\n\tgroupB\tgroupD\tgroupB\n\t"
<<"groupC\tgroupA\tgroupC\n\tgroupD\tgroupB\tgroupD\n\tgroupA\tgroupC\tgroupA\n"
<<"\nEnter your choice:\n";
cin >> strategyChoice;
switch(strategyChoice)
{
case 1:
display(4);
break;
/* case 2:
checkValidation(strategyChoice);
break;
*/
default:
cout<<"Oops!!! Wrong choice\n Enter your choice Again\n";
}
}while(strategyChoice != 1);
}
// to calculate total available seats in all rooms
int verification :: roomsCapacity()
{
totalSeats = 0;
for( j=0; j<totalRoom; j++)
{
totalSeats += ( rows[j] * cols[j] );
}
cout << "\ntotal Seats = " << totalSeats;
return(totalSeats);
}
// member function to calculate the cpacity of one group
/*void verification :: checkValidation(int strategyChoice)
{
int temp;
outFile.open("output.txt");
switch(strategyChoice)
{
case 1:
temp = display(4);
if(temp == true)
outFile << "\ncongrats!!!!!!!!!! this strategy is applicable";
if(temp == false)
outFile << "\nBadddddddddddd";
break;
/* case 2:
temp = display(4);
if(temp == tr`ue)
outFile << "\ncongrats!!!!!!!!!! this strategy is applicable ";
if(temp == false)
outFile << "\nBadddddddddddd";
break;
}
}
*/
int verification :: maxStudent(int groups)
{
min = 3265;
max = 0;
for(i=0; i<groups; i++)
{
groupArray[i] = branchStudent[i];
if(groupArray[i] < min)
{
min = groupArray[i];
minPos = i;
}
if(groupArray[i] > max)
max = groupArray[i];
}
for(i=groups; i<totalBranches; i++)
{
groupArray[minPos] += branchStudent[i];
min = max;
for(j=0; j<groups; j++)
{
if(groupArray[j] <= min)
{
min = groupArray[j];
minPos = j;
}
if(groupArray[j] > max)
max = groupArray[j];
}
}
outFile <<"\n Min group students = " << min <<"\tMax group students =" << max;
cout <<"\n Min group students = " << min <<"\tMax group students =" << max;
return(max);
}
void verification :: display(int groups)
{
outFile.open("strategyResults.txt");
groupSeats = 0;
int selection, sum =0;
if(totalBranches <groups)
{
outFile << "\n\nSorry!!!\nStrategy not possible because this strategy requires minimum 4 classes\n";
cout << "\n\nSorry!!!\nStrategy not possible because this strategy requires minimum 4 classes\n";
}
else
{
groupSeats = (roomsCapacity()) / groups;
outFile << "\ngroup seats= " << groupSeats;
cout << "\ngroup seats= " << groupSeats;
groupStudents = maxStudent(groups);
if( groupStudents > groupSeats)
{
do
{
outFile <<"\n\n\nstrategy is not possible bcz of less rooms\n\n";
cout <<"\n\n\nstrategy is not possible bcz of less rooms\n";
cout << "Would you like follow:\n1.\tStrict strategy \n2."
<<"\tStudents at consecutive places of same subject\n Enter choice";
cin >> selection;
}while(selection !=1 && selection !=2);
if(selection == 1)
{
outFile << groupStudents - groupSeats <<" More seats are required\n";
cout << groupStudents - groupSeats <<" More seats are required\n";
float extraRooms=(float) (groupStudents - groupSeats) / (32/groups);
cout <<"\n Add " << extraRooms <<" Rooms of 8 * 4 to follow this strategy where"
<<" 8 is rows and 4 is columns\n\n";
}
if(selection == 2)
{
for( i=0; i<groups; i++)
{
sum += groupArray[i];
}
if( roomsCapacity() >= sum)
{
cout << "\nTotal Students: " << sum;
cout << "\ncongratulations!!! you can get results now.";
RollNo obj;
obj.get_details();
obj.seat_alot();
obj.show_details();
}
else
{
cout<<"\nSorry :-( \nYou need to enter more rooms to follow this strategy";
}
}
}
else
{
RollNo obj;
obj.get_details();
obj.seat_alot();
obj.show_details();
}
}
}