forked from Rustam-Z/cpp-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEducation.cpp
More file actions
273 lines (256 loc) · 5.84 KB
/
Copy pathEducation.cpp
File metadata and controls
273 lines (256 loc) · 5.84 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
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
#include <iostream>
#include <string>
#include <conio.h>
#include <time.h>
#include <Windows.h>
using namespace std;
// Functions declaration
void F_First_Program_Menu();
class Education {
protected:
int HPQ;
public:
Education() {
HPQ = 0;
}
void getdata() {
cout << "\n1. Undergraduate 2. Graduate 3. Masters Degree 4. PHD\n";
cout << "Enter Educational Qualification: " ;
cin >> HPQ;
if (HPQ == 1 || HPQ == 2 || HPQ == 3 || HPQ == 4) {
}
else {
cout << "Invalid Educational Qualification. Try one more time.\n";
//Sleep(0700); Sleep(0700);
Education::getdata();
}
}
void showdata() {
if (HPQ == 1) {
cout << "Educational Qualification: Undergraduate\n";
}
else if (HPQ == 2) {
cout << "Educational Qualification: Graduate\n";
}
else if (HPQ == 3) {
cout << "Educational Qualification: Masters Degree\n";
}
else if (HPQ == 4) {
cout << "Educational Qualification: PHD\n";
}
}
};
class Staff {
protected:
string code;
string name;
public:
Staff() {
code = "0000";
name = "Unknown";
}
void getdata_name() {
cout << "Enter employee name: " ; cin >> name;
}
void getdata_code() {
cout << "Enter employee code: " ; cin >> code;
}
void showdata_name() {
cout << "Employee name: " << name << endl;
}
void showdata_code() {
cout << "Employee code: " << code << endl;
}
};
class Teacher : public Staff, public Education {
protected:
string subject;
int publications;
public:
Teacher() {
subject = "Unknown";
publications = 0;
}
void getdata() {
Staff::getdata_code();
Staff::getdata_name();
Education::getdata();
cout << "Enter subject: " ; cin >> subject;
cout << "Enter number of publications: " ; cin >> publications;
}
void showdata() {
Staff::showdata_code();
Staff::showdata_name();
Education::showdata();
cout << "Subject: " << subject << endl << "Publications: " << publications << endl;
}
};
class Officer : public Staff, public Education {
protected:
float grade;
public:
Officer() {
grade = 0.0;
}
void getdata() {
Staff::getdata_code();
Staff::getdata_name();
Education::getdata();
cout << "Enter the grade: "; cin >> grade;
}
void showdata() {
Staff::showdata_code();
Staff::showdata_name();
Education::showdata();
cout << "Officer Grade: " << grade << endl;
}
};
class Typist : public Staff {
protected:
int speed;
public:
Typist() {
speed = 0;
}
void getdata() {
Staff::getdata_code();
Staff::getdata_name();
cout << "Enter the speed (wprds/min): "; cin >> speed;
}
void showdata() {
Staff::showdata_code();
Staff::showdata_name();
cout << "Speed (words/min): " << speed << endl;
}
};
class Regular_Typist : public Typist {
protected:
float monthly_salary;
public:
Regular_Typist() {
monthly_salary = 0.0;
}
void getdata() {
Typist::getdata();
cout << "Enter the monthly salary: "; cin >> monthly_salary;
}
void showdata() {
Typist::showdata();
cout << "Monthly salary: " << monthly_salary << endl;
}
};
class Casual_Typist : public Typist {
protected:
float daily_wage;
public:
Casual_Typist() {
daily_wage = 0.0;
}
void getdata() {
Typist::getdata();
cout << "Enter the daily wage: "; cin >> daily_wage;
}
void showdata() {
Typist::showdata();
cout << "Daily wage: " << daily_wage << endl;
}
};
int main() {
//
F_First_Program_Menu();
system("pause");
return 0;
}
void F_First_Program_Menu() {
// objects
Teacher teacher;
Officer officer;
Regular_Typist regular;
Casual_Typist casual;
for (int k = 0; k < 1000; k++) {
system("cls");
cout << "\tM A I N M E N U\n";
cout << " =====================\n";
cout << " 1. Teacher\n";
cout << " 2. Officer\n";
cout << " 3. Typist\n";
cout << " 0. Back\n";
cout << " Your choice: \n";
switch (_getch())
{
case '1': {
system("cls");
cout << "\t T E A C H E R\n";
cout << "===================================\n";
teacher.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
teacher.showdata();
cout << endl << endl;
system("pause");
}break;
case '2': {
system("cls");
cout << "\t O F F I C E R\n";
cout << "===================================\n";
officer.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
officer.showdata();
cout << endl << endl;
system("pause");
}break;
case '3': {
for (int l = 0; l < 1000; l++) {
system("cls");
cout << "\t T Y P I S T\n";
cout << "===================================\n";
cout << " 1. Regular typist\n"; cout << " 2. Casual typist\n"; cout << " 0. Back\n"; cout << " Your choice: \n";
switch (_getch())
{
case '1': {
system("cls");
cout << "\t R E G U L A R T Y P I S T\n";
cout << "===================================\n";
regular.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
regular.showdata();
cout << endl << endl;
system("pause");
}
break;
case '2': {
system("cls");
cout << "\t C A S U A L T Y P I S T\n";
cout << "===================================\n";
casual.getdata();
cout << "\n\n\tThe given information:\n";
cout << "===================================\n";
casual.showdata();
cout << endl << endl;
system("pause");
}
break;
case '0': {
system("cls");
l = 1000;
}break;
default: {cout << endl << endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700); Sleep(0700);
}break;
} // switch
} // for
}break;
case '0': {
system("cls");
k = 1000;
} break;
default: { cout << endl << endl;
cout << "\t\t Your choice is not abailable in Menu. \n\t\t Please try one more time.\n";
Sleep(0700); Sleep(0700);
}break;
} // switch
} // for loop
}