-
Notifications
You must be signed in to change notification settings - Fork 0
/
CandidateDataBackend.cpp
228 lines (175 loc) · 4.54 KB
/
CandidateDataBackend.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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
#include <bits/stdc++.h>
//'max' denotes the maximum
//number of candidates
#define max 30
using namespace std;
//Structure containing
//necessary variables
struct candidate_data
{
//variable containing candidate name
string name;
//semester grade point average (SGPA)
float semester_grade_point;
//roll/registration number
long int reg_roll_no;
//does the student prefer paperback or sofcopy?
string preference;
};
//condition for variable (num <= max)
int num;
//DisplayMenu function prototype
void DisplayMenu();
//user defined datatype derived from the above structure
candidate_data candid_container[max];
//function to build the dataframe
void build()
{
cout << "\nBuild The Table\n";
cout << "Enter the number of entries required (max "<<max<<"): ";
cin >> num;
//to check if number of data inputs cause overflow
if (num > max)
{
cout << "Ooops! The maximum number of entries must be " <<max<<"\n";
//if so, assign max to variable num
num = max;
}
//data entry begins here
cout << "\nEnter the following data: \n";
//enter data untill the iteration ends
for (int i = 0; i < num; i++)
{
//name of candidate
cout << "\nCandidate Name: ";
cin >> candid_container[i].name;
//semester grade point (SGPA)
cout << "\nSemester GPA: ";
cin >> candid_container[i].semester_grade_point;
//candidate registration number
cout << "\nRegist. No.: ";
cin >> candid_container[i].reg_roll_no;
//candidate preference
cout << "\nMaterial Preference (Softcopy/Paperback): ";
cin >> candid_container[i].preference;
}
//function prototype used
//to display the data entry
DisplayMenu();
}
//function to input new data
//updating the previous table
void insert()
{
if (num < max)
{
//update the number
//w.r.t constraints
int i = num;
num++;
//declaring the data entry
cout << "\nData Entry:\n";
//name of candidate
cout << "\nCandidate Name: ";
cin >> candid_container[i].name;
//semester grade point (SGPA)
cout << "\nSemester GPA: ";
cin >> candid_container[i].semester_grade_point;
//candidate registration number
cout << "\nRegist. No.: ";
cin >> candid_container[i].reg_roll_no;
//candidate preference
cout << "\nMaterial Preference (Softcopy/Paperback): ";
cin >> candid_container[i].preference;
}
else
{
//case when num goes beyond max
cout << "\nWarning! Data Overflow Detected\n";
}
//prototype used to display data
DisplayMenu();
}
//function to output the table
void DisplayTable()
{
cout<<"Candidate Name Semester GPA Regist. Number Preference "<<endl;
cout<<"-----------------------------------------------------------"<<endl;
for(int i = 0; i <= num-1; i++)
{
cout<<candid_container[i].name;
cout<<setw(17)<<candid_container[i].semester_grade_point;
cout<<setw(17)<<candid_container[i].reg_roll_no;
cout<<setw(17)<<candid_container[i].preference;
cout<<endl;
}
//prototype used to display data
DisplayMenu();
}
void searchRecord()
{
//enter candidate's name to be searched
cout << "\nEnter The Candidate's Registration Number: ";
long int reg_num;
cin >> reg_num;
for (int i = 0; i < num; i++) {
// If the name is found in the built record
//show the candidate's data
if (candid_container[i].reg_roll_no == reg_num) {
cout << "\nCandidate Name: "<< candid_container[i].name << "\n";
cout << "Semester GPA: "<< candid_container[i].semester_grade_point << "\n";
cout << "Regist. No.: "<< candid_container[i].reg_roll_no << "\n";
cout << "Material Preference: "<< candid_container[i].preference << "\n";
break;
}
}
//prototype used to display data
DisplayMenu();
}
//function used to display menu
void DisplayMenu()
{
cout << "\n\n-----------------------------------------------------------\n\n";
cout << "\nWelcome To The Portal:\n";
cout << "*********************\n\n";
cout << "To Build Candidate Data (Press 1)\n";
cout << "To Insert New Data (Press 2)\n";
cout << "To Display The Candidate Data (Press 3)\n";
cout << "To Search For A Candidate (Press 4)\n";
cout << "For Exit (Press 5)\n";
cout << "\n";
int option;
cin >> option;
if (option == 1)
{
build();
}
else if (option == 2)
{
insert();
}
else if (option == 3)
{
DisplayTable();
}
else if (option == 4)
{
searchRecord();
}
else if (option == 5)
{
return;
}
else
{
DisplayMenu();
}
}
//main function
int main()
{
//clearscreen function
//system("cls");
DisplayMenu();
return 0;
}