-
Notifications
You must be signed in to change notification settings - Fork 0
/
dept.cpp
executable file
·865 lines (836 loc) · 18.8 KB
/
dept.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
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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
//***************************************************************************
/**********************PROJECT DEPARTMENTAL STORE******************************/
//***************************************************************************
/**********************INCLUDED HEADER FILES**********************************/
#include<fstream.h>
#include<string.h>
#include<stdio.h>
#include<process.h>
/*****************************************************************************/
int z=-1;
char comments[50];
/******STRUCTURE PURCHASE STORES DETAILS OF ITEMS PURCHASED BY CUSTOMER*****/
struct purchase
{
char c[3];
char n[30];
float p;
int count;
}it[300];
/******CLASS DETAILS FOR BILLING PURPOSE**************/
class details
{
private:
char name[30];
char address[50];
int phno;
public:
void getdetails(void)/******FOR TAKING PERSONAL DETAILS FROM THE CUSTOMER*****/
{
char ch;
cout<<"\n\nPlease enter your Personal Details\n";
cout<<"Your name is : ";
cin>>ch;
cin.getline(name,30);
cout<<"\nYour address : ";
cin.getline(address,50);
cout<<"\nYour phone number is : ";
cin>>phno;
}
void putdetails();
}d;
void details::putdetails(void)/*****BILL PROCESSING*****/
{
int j=0,i=0;
float tax,disc,check=0,t=0,tot=0;
int GRT;
char ch;
cout<<"\n\nYour name is : ";
cout.write(name,30);
cout<<"\nYour address is : ";
cout.write(address,50);
cout<<"\nYour phone number is : ";
cout<<phno;
cout<<endl;
i=z;
for(j=0;j<=i;j++)
{
t=it[j].p*it[j].count;
cout<<"\nItem Code:"<<it[j].c<<" Name:"<<it[j].n; //item nos
cout<<" Price Rs "<<it[j].p<<" Purchased:"<<it[j].count;
cout<<" Total Rs "<<t<<endl;
tot=tot+t;
}
cout<<endl;
if(tot>1000)
{
cout<<"\nTotal Amount Rs "<<tot;
tax=tot*0.125;
cout<<"\nTotal Tax Rs "<<tax;
disc=0.2*tot;
cout<<"\nTotal Discount Rs "<<disc;
GRT=tot+tax-disc;
cout<<"\nTotal Amount Payable Rs "<<GRT;
}
else
{
cout<<"\nTotal Amount Rs "<<tot;
tax=tot*0.125;
cout<<"\nTotal Tax Rs "<<tax;
GRT=tot+tax;
cout<<"\nTotal Amount Payable Rs "<<GRT;
}
if(GRT<0)
{
cout<<"\nTHANK YOU SIR,SEE YOU SOON";
exit(0);
}
}
int homeutilities(void)/*int departmental_store(int x) invokes this function*/
/*when customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE HOMEUTILITIES SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Homeutilities Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("HOMEUTILITIES",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("HOMEUTILITIES",ios::in);
fin.seekg(0);
while(fin)
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Homeutilities section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int fooditems(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE FOODITEMS SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Fooditems Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("FOODITEM",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("FOODITEM",ios::in);
fin.seekg(0);
while(fin)
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Fooditems section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int bags(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE BAGS SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Bags Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("BAGS",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("BAGS",ios::in);
fin.seekg(0);
while(fin)
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Bags section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int toys()/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE TOYS SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Toys Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("TOYS",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("TOYS",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Toys section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int watch()/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE WRIST WATCH SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Wrist Watch Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("WATCH",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("WATCH",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Wrist Watch section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int garment(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE GARMENTS SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Garments Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("GARMENT",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
//if(code[0]=='G')
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("GARMENT",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Garments section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int footwear(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE FOOTWEAR SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Footwear Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("FOOTWEAR",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("FOOTWEAR",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Footwear section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int mobile(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE MOBILE SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Mobile Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("MOBILE",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("MOBILE",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Mobile section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int laptop(void)/*int departmental_store(int x) invokes this function when*/
/*customer wants to buy from this section*/
{
char section[30],code[3],name[30],ans='y',c='y',c1='y',i[3],ch;
float price;
cout<<"\nWELCOME TO THE LAPTOP SECTON\n";
while(c=='y'||c=='Y')
{
cout<<"\nHere is the Laptop Menu ";
cout<<"being displayed in the format\n";
cout<<"\nItemcode.Name Price\n\n";
ifstream fin("LAPTOP",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<code<<"."<<name<<" Rs "<<price<<"\n";
}
fin.close();
cout<<"\nWant to buy any item?(y/n)";
cin>>c1;
if(c1=='n'||c1=='N')
return 0;
++z;
cout<<"\nEnter item code:";
cin>>i;
fin.open("LAPTOP",ios::in);
fin.seekg(0);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(i,code)==0)
{
strcpy(it[z].c,code);
strcpy(it[z].n,name);
it[z].p=price;
cout<<"\nHow many "<<it[z].n<<" do you want to buy?\n";
cin>>it[z].count;
break;
}
}
fin.close();
cout<<"\nWant to buy more items from Laptop section?(y/n)";
cin>>c;
if(c=='n'||c=='N')
return 0;
}
}
int departmental_store(int x)/*invokes a function according to user's choice*/
/*which he enters in main() function*/
{
if(x==1)
{
homeutilities();return 0;
}
if(x==2)
{
fooditems();return 0;
}
if(x==3)
{
bags();return 0;
}
if(x==4)
{
toys();return 0;
}
if(x==5)
{
watch();return 0;
}
if(x==6)
{
garment();return 0;
}
if(x==7)
{
footwear();return 0;
}
if(x==8)
{
mobile();return 0;
}
if(x==9)
{
laptop();return 0;
}
}
int shopping(void)/*invoked from main if someone wants to do shopping*/
{
char ch='y',ch1='y';
int j=0;
cout<<"\nIf you purchase items worth more than Rs 1000\nyou will get 20% cashback\n";
while(ch1=='y'||ch1=='Y')
{
cout<<"\nHERE IS THE MENU:";
cout<<"\n1.Homeutilities";
cout<<"\n2.Fooditems";
cout<<"\n3.Bags";
cout<<"\n4.Toys";
cout<<"\n5.Wrist Watch";
cout<<"\n6.Garment";
cout<<"\n7.Footwear";
cout<<"\n8.Mobiles";
cout<<"\n9.Laptop";
cout<<"\nWant to enter any section sir?(y/n)";
cin>>ch;
if(ch=='n'||ch=='N')
{
cout<<"\nTHANK YOU SIR,SEE YOU SOON";
exit(0);
}
cout<<"\nEnter your choice:";
cin>>j;
departmental_store(j);
cout<<"\nWant to do more shopping?(y/n)";
cin>>ch1;
}
d.getdetails();
cout<<"\n\n";
cout<<"\nHere is your bill:\n";
d.putdetails();
cout<<"\n\n";
}
int mod()/*invoked from main if an authorized person want to do */
/*modify details of dept store.This function provides 4 options*/
/*append,modify and delete*/
{
char p[30];
int k;
cout<<"\nENTER PASSWORD PLEASE\n";
gets(p);
if(strcmp(p,"Hesoyam")!=0)
{
cout<<"\nUNAUTHORIZED PERSON!!\n";
exit(0);
}
cout<<"\nWHAT DO YOU WANT TO DO?\n";
cout<<"1.Add/Append\n";
cout<<"2.Modify existing data\n";
cout<<"3.Delete existing data\n";
cout<<"4.Go back to Store\n";
cout<<"Enter Choice:";
cin>>k;
if(k==1)
{
char ch[20];
cout<<"\nWhich file will you process:\n";
cout<<"HOMEUTILITIES,FOODITEM,BAGS,GARMENT,MOBILE,LAPTOP,WATCH,TOYS,FOOTWEAR\n";
gets(ch);
cout<<"\nHere is the previous data\n";
ifstream fin(ch,ios::in);
char code[3];
char name[30];
float price;
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
cout<<"\n\nNow Append\n";
ofstream fout(ch,ios::app|ios::out);
char ans='y';
while(ans=='y')
{
cout<<"\nEnter Product code:";
cin>>code;
cout<<"\nEnter Product name:";
cin>>name;
cout<<"\nEnter Product price:";
cin>>price;
cout<<"Do you want to enter more items(y/n)";
cin>>ans;
fout<<'\n'<<code<<'\n'<<name<<'\n'<<price<<'\n';
}
fout.close();
cout<<"\nHere is the new data\n";
fin.open(ch,ios::in);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
}
if(k==2)
{
char ch[20],c[3],o;
long pos;
cout<<"\nWhich file will you process:\n";
cout<<"HOMEUTILITIES,FOODITEM,BAGS,GARMENT,MOBILE,LAPTOP,WATCH,TOYS,FOOTWEAR\n";
gets(ch);
cout<<"\nHere is the previous data\n";
ifstream fin(ch,ios::in);
char code[3];
char name[30];
float price;
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
cout<<"\n\n";
cout<<"Enter the code for which you will modify corresponding details:";
gets(c);
cout<<"\n\n";
fin.open(ch,ios::in);
ofstream fo("t",ios::out|ios::app);
while(!fin.eof())
{
pos=fin.tellg();
fin>>code;
fin>>name;
fin>>price;
fo<<code<<'\n'<<name<<'\n'<<price<<'\n';
if(strcmp(c,code)==0)
{
cout<<"\nEnter Code: ";cin>>code;
cout<<"\nEnter Name: ";cin>>name;
cout<<"\nEnter Price: ";cin>>price;
fo<<code<<'\n'<<name<<'\n'<<price<<'\n';
}
}
fo.close();
fin.close();
cout<<"\n\n";
cout<<"\nHere is the data after modification\n\n";
remove(ch);
rename("t",ch);
fin.open(ch,ios::in);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
fin>>o;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
}
if(k==3)
{
char ch[20],c[3];
cout<<"\nWhich file will you process:\n";
cout<<"HOMEUTILITIES,FOODITEM,BAGS,GARMENT,MOBILE,LAPTOP,WATCH,TOYS,FOOTWEAR\n";
gets(ch);
cout<<"\nHere is the previous data\n";
ifstream fin(ch,ios::in);
char code[3];
char name[30];
float price;
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
cout<<"\n\n";
cout<<"Enter the code for which you will delete corresponding details:";
gets(c);
ofstream fout("t",ios::app|ios::out);
fin.open(ch,ios::in);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
if(strcmp(c,code)!=0)
{
fout<<code<<'\n'<<name<<'\n'<<price<<'\n';
}
}
fout.close();
fin.close();
remove(ch);
rename("t",ch);
cout<<"\n\n";
cout<<"\nHere is the data after deletion\n\n";
fin.open(ch,ios::in);
while(!fin.eof())
{
fin>>code;
fin>>name;
fin>>price;
cout<<"CODE:"<<code<<" NAME:"<<name<<" PRICE:"<<price<<endl;
}
fin.close();
}
if(k==4)
return 0;
}
void main()
{
int q;
char ans='n';
while(ans=='n'||ans=='N')
{
/***********MAIN MENU*************/
cout<<"\nWELCOME TO THE DEPARTMENTAL STORE\n";
cout<<"\nWHAT DO YOU WANT TO DO?\n";
cout<<"1.SHOPPING\n";
cout<<"2.*MODIFY DATA*(FOR AUTHORIZED STAFF MEMBERS IN CHARGE ONLY)\n";
cout<<"\nEnter Choice:";
cin>>q;
if(q==1)
shopping();
if(q==2)
mod();
/***********TO EXIT*************/
cout<<"\n\nDO YOU WANT TO LEAVE THE STORE?(y,n)";
cin>>ans;
}
cout<<"\nEnter your comments and views\n";
fflush(stdin);//to clear input buffer
gets(comments);
cout<<"THANK YOU SIR,SEE YOU SOON";
}