-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFS Mini project.cpp
More file actions
551 lines (477 loc) · 9.76 KB
/
FS Mini project.cpp
File metadata and controls
551 lines (477 loc) · 9.76 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
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
#include<iostream>
#include<string.h>
#include<math.h>
#include<fstream>
#include<conio.h>
#include<process.h>
#include<stdlib.h>
#include<stdio.h>
#include<iomanip>
using namespace std;
fstream data;
char Baf[80],Buffer[80];
unsigned long int total = 0;
char charr[50];
class member
{
public: int flag;
char name[20],num[20];
unsigned long int duration;
};
class items
{
public:
char num[20],name[20];
unsigned long int dur;
}acc;
member rec[10];
int no,k;
int Hash(int m)
{
int r,q;
r=m%10;
q=rand()/10;
q=m/10;
k=(q+r+7)%10;
return k;
}
void unpack()
{ int i=0;
fstream in;
in.open("ca.txt",ios::in);
char buf[80];
while(!in.eof())
{
in.getline(rec[i].name,50,'|');
in.getline(rec[i].num,50,'|');
in.getline(charr,50,'\n');
rec[i].duration=atoi(charr);
i++;
}
in.close();
}
void search()
{
int m,i,f=0,ff=0;
char num[15];
cout<<endl;
cout<<"Enter Workout Plan: ";
cin>>num;
m =atoi(num);
k = Hash(m);
unpack();
for(i=0;i<10;i++)
{
if((strcmp(rec[k%10].num,num))==0 && ff==0)
{
ff=1;
cout<<"\n Available workouts for today are: "<<k<<": "<<endl;
cout<<"\n\n\tPLAN NUMBER : "<<rec[k%10].num<<"\t"<<"\n\n\tWORKOUT PLAN : "<<rec[k%10].name<<"\t"<<"\n\n\tDURATION(in mins) : "<<rec[k%10].duration<<"\n";
f=1;
}
k=k+1;
}
if(f!=1)
cout<<"\n Unfortunately, the workout isn't available for today.' :( \n"; getch();
return;
}
void deletee()
{
int ch;
system("cls");
cout<<"\n\n\t\t REMOVING TODAY'S SCHEDULE'............\n\n";
cout<<" \n\n\n 1. Specific Workout Plans ";
cout<<" \n\n\n 2. All Workout Plans ";
cout<<" \n\n\n 3. Exit ";
cout<<" \n\n\n\t ENTER YOUR CHOICE : ";
cin>>ch;
switch(ch)
{
case 1:
{
int m,i,f=0,cc;
char vv[20];
char tt[20],num[20];
unsigned long dur;
cout<<endl;
cout<<"Enter Plan Number : ";
cin>>num;
m=atoi(num);
k=Hash(m);
unpack();
for(i=0;i<10;i++)
{
if((strcmp(rec[k%10].num,num))==0)
{
f=1;
cout<<" \n\n\t\t WORKOUT REMOVED :) " ;
rec[k%10].flag=0;
strcpy(rec[k%10].num,"zzzzzzzzzzzzzzzzzzz");
total = total - rec[k%10].duration;
break;
}
k=k+1;
}
fstream f1;
f1.open("ca.txt",ios::out);
for(i=0;i<10;i++)
{
if(rec[i].flag==0)
{
f1<<"#|#"<<"\n";}
else
{
f1<<rec[i].num<<"|"<<rec[i].name<<"|"<<rec[i].duration<<"\n";}
}
f1.close();
if(f!=1)
cout<<"\n not found \n"; getch();
return;
}
case 2:
{
fstream f12;
f12.open("nidhi.txt",ios::out);
for(int i=0;i<10;i++)
{
if(rec[i].flag==0)
f12<<"#|#"<<"\n";
else
{
rec[i].flag=0;
strcpy(rec[i].num,"zzzzzzzzzzzzzzzzzzz");
f12<<"#|#"<<"\n";
}
}
f12.close();
total = 0;
cout<<" \n\n\t\tREMOVED THE ENTIRE WORKOUT PLAN FOR TODAY. :) " ;
getch();
break;
}
}
}
void disp()
{
system("cls");
cout<<"\n\n\t\tDISPLAYING TODAY'S SCHEDULE'...............\n";
cout<<"\n\n\nWORKOUT PLAN \t PLAN NUMBER \t duration OF TIME\n";
cout<<"###########################################################\n";
for(int i=0;i<10;i++)
{
if(rec[i].flag==1)
cout<<endl<<rec[i].name<<"\t\t"<<rec[i].num<<"\t\t"<<rec[i].duration<<"\n";
}
getch();
}
void additems()
{
system("cls");
cout<<"\n\n\t\tINSERTION OF WORKOUT PLANS....................\n\n";
char Buffer[51],offset[10];
char itno[20],baa[50],num[20],name[20],charr[20];
unsigned long int a;
int flaggg=0;
char ch='y';
while(ch=='y')
{
data.open("kshitij.txt",ios::in);
cout<<"\n Enter Plan Number: ";
cin>>acc.num;
if(!data)
flaggg=2;
while(!data.eof() && flaggg==0)
{
data.getline(num,50,'|');
data.getline(name,50,'|');
data.getline(charr,50,'\n');
a=atoi(charr);
if((strcmp(acc.num,num))==0)
{
flaggg=1;
cout<<"\n\n\t\t Choose a differnt plan number";
getch();
}
if(data.eof())
break;
}
data.close();
if(flaggg==1)
break;
if(flaggg != 1)
{
cout<<"\n Enter Workout: ";
cin>>acc.name;
cout<<"\n Enter Duration of the workout(in mins): ";
cin>>acc.dur;
data.open("kshitij.txt",ios::app);
data<<acc.num<<'|'<<acc.name<<'|'<<acc.dur<<'\n';
data.close();
cout<<" \n\n\n\n\n NEW WORKOUT ADDED TO THE SCHEDULE......!! ";
cout<<"\n\n\n\t\t\tClick y to Add one more : " ;
cin>>ch;
}
}
}
void viewitems()
{
system("cls");
cout<<"\n\n\t\tDISPLAYING TODAY'S WORKOUT PLAN SCHEDULE'......................\n\n";
data.open("kshitij.txt",ios::in);
cout<<"\n PLAN NUMBER \t WORKOUT PLAN \t DURATION(in mins)\n";
cout<<"\n***********************************************************\n";
while(!data.eof())
{
data.getline(acc.num,50,'|');
data.getline(acc.name,50,'|');
data.getline(charr,50,'\n');
acc.dur=atoi(charr);
if(data.eof())
break;
for(int i=0;i<strlen(Baf);i++)
{
cout<<endl<<Baf[i]<<" ";
}
cout<<"\n "<<acc.num<<" \t "<<acc.name<<" \t\t"<<acc.dur;
}
data.close();
getch();
}
void searchitem()
{
char itno[20],baa[50],num[20],name[20],charr[20];
unsigned long int a;
int flaggg=0;
fstream ff;
ff.open("kshitij.txt",ios::in);
cout<<"\n\n\t Enter Plan Number : ";
cin>>itno;
while(!ff.eof())
{
ff.getline(num,50,'|');
ff.getline(name,50,'|');
ff.getline(charr,50,'\n');
a=atoi(charr);
if((strcmp(itno,num))==0)
{
flaggg=1;
cout<<"\n\n\tWorkout Plan : "<<name<<"\n\n\tDuration of Workout(in mins) : "<<a;
}
if(ff.eof())
break;
}
if(flaggg == 0)
cout<<"\n\n\t\tWORKOUT NOT FOUND :( ";
getch();
ff.close();
}
int main()
{
int m,ch,chh;
char num[20],name[20];
unsigned int duration;
while(1)
{
system("cls");
cout<<"\n\n\t\t-----------NK GYM-----------------\n\n\n";
cout<<"\n\n Press 1 for MEMBER - Choose your Workout routine for today";
cout<<"\n\n Press 2 for TRAINER - Add all the workout which will be available today!";
cout<<"\n\n Press 3 for Viewing lis of workout plans available at NK Gym";
cout<<"\n\n Press 4 for EXIT";
cout<<"\n\n\t Enter your Choice : ";
cin>>ch;
switch(ch)
{
case 1:
cout<<"Enter your name\n";
cin>>name;
do{
system("cls");
cout<<"\n\n\t\tHello " <<name<< "\n\n\n";
cout<<"\n\n Press 1 for Adding new workout to your workout schedule";
cout<<"\n\n Press 2 for Viewing your current workout schedule";
cout<<"\n\n Press 3 for Removing workout from your workout schedule";
cout<<"\n\n Press 4 for Searching for a specific workout in your workout schedule";
cout<<"\n\n Press 5 to GO BACK";
cout<<"\n\n PRESS 6 TO SEE YOUR POSSIBLE RESULT " ;
cout<<"\n\n\n\n\t Enter your Choice : ";
cin>>chh;
switch(chh)
{
case 1:
system("cls");
cout<<"\n\t\tADDING WORKOUT...........\n\n";
cout<<"\nEnter how many workout session you want to do today\n : ";
cin>>no;
if(no<=10)
{
for(int l=0;l<no;l++)
rec[l].flag=0;
for(int i=0;i<no;i++)
{
int ff=0;
cout<<"\n Enter Plan No : ";
cin>>num;
char Baf[80];
data.open("kshitij.txt",ios::in);
while(!data.eof())
{
if(data.eof())
break;
data.getline(acc.num,50,'|');
data.getline(acc.name,50,'|');
data.getline(charr,50,'\n');
acc.dur=atoi(charr);
for(int i=0;i<strlen(Baf);i++)
{
cout<<Baf[i]<<" ";
}
if(strcmp(acc.num,num)==0)
{
ff=1;
strcpy(name,acc.name);
duration = acc.dur;
cout<<"\n\t WORKOUT NAME :"<<name<<"\n\t DURATION OF THE WORKOUT(in mins) :"<<duration<<"\n\n";
total = total + duration;
}
}
data.close();
if(ff==1)
{
m=atoi(num);
k=Hash(m);
cout<<"address: "<<k<<"\n";
if(rec[k].flag==0)
{
strcpy(rec[k].name,name);
strcpy(rec[k].num,num);
rec[k].duration=duration;
rec[k].flag=1;
}
else
{
for(int j=k+1;j%10<10;j++)
{
if(rec[j%10].flag==0)
{
strcpy(rec[j%10].name,name);
strcpy(rec[j%10].num,num);
rec[j%10].duration=duration;
rec[j%10].flag=1;
break;
}
}
}
}
else
cout<<"\n\n\t\t\ WORKOUT ISNT AVAILABLE TODAY.!!!!!!";
}
cout<<"\n\n\tTOTAL DURATION OF TODAY'S WORKOUT (in mins) : "<<total;
fstream f1;
f1.open("nidhi.txt",ios::out);
for(int i=0;i<10;i++)
{
if(rec[i].flag==0)
f1<<"#|#"<<"\n";
else
f1<<rec[i].name<<"|"<<rec[i].num<<"|"<<rec[i].duration<<"\n";
}
f1.close();
}getch();
break;
case 2:
disp();
break;
case 3:
deletee();
break;
case 4:
search();
break;
case 6:
int cal;
cal=500*(total/60);
system("cls");
cout<< "Your body can stand almost anything, its your mind that you have to continue. Remember pain is temporary, result is permanent.\n";
cout<< "-------------------------------DID YOU KNOW!----------------------------------\n";
cout<<"Each of our workout plans are curated in such way you loose approx *400-500* calories in one hour\n";
cout<<"\n\n\n\n*******************************************************\n\n\n\n";
cout<<"\nYOUR TOTAL HOURS IN GYM TODAY : "<<total;
cout<<" which means you will lose approx " <<cal<< " calories today.\n";
cout<<"Dont lose hope! Lose calories! See you there today.\n";
fstream f12;
f12.open("ca.txt",ios::out);
for(int i=0;i<10;i++)
{
if(rec[i].flag==0)
f12<<"#|#"<<"\n";
else
{
rec[i].flag=0;
strcpy(rec[i].num,"zzzzzzzzzzzzzzzzzzz");
f12<<"#|#"<<"\n";
}
}
f12.close();
total = 0;
cout<<"\n\n\n\n\t\t REMEMBER IT BEGINS WITH I :)";
getch();
break;
}
}while(chh!=5);
break;
case 2:
{
int flag=1;
system("cls");
cout<<"\nPlease enter your name:\n ";
char name[20];
cin>>name;
cout<<"\nEnter your password: \n";
char pass[10];
cin>>pass;
if(strcmp(pass,"momos")==0)
{
system("cls");
cout<<"\n\tWelcome "<<name<<endl;
getch();
}
else
{
cout<<"INVALID PASSWORD!!!! \n";
cout<<"enter 1 to exit, any other to continue";
flag=0;
}
if(flag==1)
{
do
{
cout<<"\n\n Press 1 for ADDING NEW WORKOUT PLANS";
cout<<"\n\n Press 2 to SEARCH FOR AN EXISTING WORKOUT";
cout<<"\n\n Press 3 to GO BACK";
cout<<"\n\n\t Enter your Choice : ";
cin>>chh;
switch(chh)
{
case 1:
additems();
break;
case 2:
searchitem();
break;
case 3:
break;
}
}while(chh!=3);
}
}
case 3:
{
viewitems();
break;
}
case 4:
exit(0);
}
}
}