-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcode.cpp
More file actions
299 lines (267 loc) · 8.78 KB
/
code.cpp
File metadata and controls
299 lines (267 loc) · 8.78 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
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
#include<iostream>
#include<cctype>
#include<string>
#include<algorithm>
#include<stdlib.h>
#include<fstream>
using namespace std;
class student
{ private:
string studentName;
string fatherName;
string Class;
string studentAge;
string studentEmail;
string contactNo;
public:
void registration()
{
int a=0;
cout<<"Enter Your Name: "<<endl;
getline(cin >> ws,studentName);
studentName.erase(remove(studentName.begin(), studentName.end(), ' '), studentName.end());
while ( a==0) {
for (int i = 0; i <studentName.length(); i++) {
if(isalpha(studentName[i])) {
a=1;
}
else { cout << "Enter a valid name: " <<endl; getline(cin >> ws,studentName);
studentName.erase(remove(studentName.begin(), studentName.end(), ' '), studentName.end());
}
}
}
int b=0;
cout<<"Enter Your Father's name: "<<endl;
getline(cin >> ws,fatherName);
fatherName.erase(remove(fatherName.begin(), fatherName.end(), ' '), fatherName.end());
while ( b==0) {
for (int i = 0; i <fatherName.length(); i++) {
if(isalpha(fatherName[i]))
{
b=1;
}
else { cout << "Enter a valid name: " <<endl; getline(cin >> ws,fatherName);
fatherName.erase(remove(fatherName.begin(), fatherName.end(), ' '), fatherName.end());
}
}
}
int c=0;
cout<<"Enter your age: "<<endl;
cin >> studentAge;
while ( c==0) {
for (int i = 0; i <studentAge.length(); i++) {
if(isdigit(studentAge[i])) {
c=1;
}
else { cout << "Enter a valid input: " <<endl; cin >> studentAge;
}
}
}
int d=0;
cout<<"Enter your class: "<<endl;
cin>>Class;
while ( d==0) {
for (int i = 0; i <Class.length(); i++) {
if(isdigit(Class[i])) {
d=1;
}
else { cout << "Enter a valid input: " <<endl; cin >> Class;
}
}
}
cout<<"Enter your gmail ID:"<<endl;
cin >> studentEmail;
cout<<"Enter your contactNo: "<<endl;
cin>>contactNo;
int e=0;
while(e==0)
{
if(contactNo.length()==11)
break;
else
{cout<<"Enter a valid input: "<<endl; cin>>contactNo;
}
}
}
void print(){
cout<<"Student's name: "<<studentName<<endl;
cout<<"Father's name: "<<fatherName<<endl;
cout<<"Class: "<<Class<<endl;
}
};
class admin
{
private:
string adminID, adminPwd, adminName;
public:
void login()
{cout<<"Enter you ID: "; cin>>adminID;
cout<<"Enter you password: " ;cin>>adminPwd;
if (adminPwd=="123" ) {
cout<<"Your password is correct."<<endl;
system("pause");
system ("CLS");
}
else {
cout<<"Incorrect password, access denied!";
system("pause");
system ("CLS");
}
}
void viewRules()
{
cout<< "1- Smoking, Alcohol & Narcotic consumption is strictly prohibited in and around the Hostel premises."<<endl;
cout<< "2- Strict adherence to the prescribed dress code is required. Decency in dressing & demeanor is a must."<<endl;
cout<< "3- Loitering in the Hostel campus during the class hours will not be appreciated."<<endl;
cout<< "4- The Management & Staff will not be responsible for personal belongings."<<endl;
cout<< "5- Late comers will be penalized."<<endl;
cout<< "6- Students must keep the Campus & Rooms clean. Defacing walls, equipment, furniture etc., is strictly prohibited."<<endl;
cout<< "7- Birthday/Other Celebrations are strictly prohibited in Hostel."<<endl;
cout<< "8- Students must turn off all the electrical equipments & lights before leaving their rooms."<<endl;
cout<< "9- Students are not allowed to organize any group activities in their room."<<endl;
cout<< "10- Tipping of Wardens, Security Guards, Cleaning staff etc., is not permitted."<<endl;
}
};
class room {
private:
int roomType;
public:
double roomPay;
public:
void chooseRoom() {
cout << "\nPlease press a number to choose your room: ";
cout << "\n1.Single\n2.Shared\n";
cin >> roomType;
switch(roomType){
case 1:
roomPay=1000;
break;
case 2:
roomPay=400;
break;
default:
cout << "You did not enter a valid choice";
}
}
};
class services {
private:
bool breakfast, dinner, tv, laundary, gym, microwave, fridge;
public:
double servPay;
int ans;
char quit='n';
public:
void calculateServicePay() {
for (char quit ='n'; quit='y';) {
cout << "\n\nPlease press a number to choose services from below: "<< endl;
cout << "1.Breakfast\n2.Dinner\n3.TV\n4.Laundary\n5.Gym\n6.Microwave\n7.Fridge\n";
cin >> ans;
if (ans>7) {
cout << "Enter a valid between 1-7"<< endl;
servPay-=50;
}
servPay+=50;
cout << "Do you want to choose more services (y/n)? " ; cin >> quit;
if (quit=='n')
{break;}
}
cout << "\nYour total service pay is: " << servPay << " rupees"<< endl;
}
};
class payment{
private:
student s;
services s1;
room r1;
double x, y,amount;
public:
void generateVoucher(){
s.registration();
s1.calculateServicePay();
r1.chooseRoom();
x=s1.servPay;
y=r1.roomPay;
amount = x+y;
amount+=5000;
cout<<"\n\n\n\t\t\t\tFee Voucher"<<endl;
cout<<"Pakistan Islamic bank Ltd" <<endl;
cout<<"Ac # (099)04226001"<<endl;
cout<<"Students Hostel"<<endl;
cout<<"Issue date\t\t"<<"Due date"<<endl;
cout<<"6/7/2022. \t\t"<<"10/7/2022."<<endl<<endl;
s.print();
//generate column
cout<<"Fee description:\t"<<"Amount:"<<endl;
cout<<"Registration Fee\t"<<"5000"<<endl;
cout<<"Monthly Fee\t\t"<<x+y<<endl;
cout<<"Amount to be paid\t"<<amount<<endl;
cout<<"-Fee is payable advance in every month"<<endl;
cout<<"-Fee once paid is non-transferable and non-refundable"<<endl;
cout<<"-Fee will not be accepted in installments"<<endl;
cout<<"-Fee will not be accepted without fee voucher"<<endl;
cout<<"-For further details contact: 03453107993"<<endl;
cout<<"-Fee voucher can be deposited into Pakistan Islamic Bank Ltd."<<endl;
}
};
int main()
{
system("Color E2");
services s1;
student s;
payment p;
admin a1;
int key;
char ch;
cout << "\n\t\t\t\t\t\tHOSTEL MANAGEMENT SYSTEM\n "<< endl;
do
{
cout << "\nAre you admin or a student?\n 1.Admin\n 2.Student\n "<< endl;
cout << " Enter your choice : " ;
cin >> key;
switch (key)
{
case 1:
{
cout << "\n\tWelcome Admin!\n "<< endl;
a1.login();
break;
}
case 2:
{
int key;
char ch;
do
{
cout << "\nWhat do you want to do?\n 1.View Rules & Regulations\n 2.Register "<< endl;
cout << "\nEnter your choice : " ;
cin >> key;
switch (key)
{
case 1:
{
a1.viewRules();
break;
}
case 2:
{
p.generateVoucher();
break;
}
default:
cout << "\nInvalid choice ";
}
cout << "\nDo you want to continue as student? (y / n) ";
cin >> ch;
} while (ch =='y');
system ("CLS");
break;
}
default:
cout << "\nInvalid choice ";
}
cout << "\nDo you want to continue?(y / n) ";
cin >> ch;
} while (ch =='y');
system ("CLS");
exit(0);}