-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSBS.cpp
244 lines (200 loc) · 4.58 KB
/
SBS.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
//Developer: Supriyo
#include<iostream>
#include<process.h>
#include<fstream>
#include <stdlib.h>
using namespace std;
class head
{
char Iname[50][50];
public:
int totalitems;
float Qty[3];
float price[3];
int vatprice[3];
int tprice[3];
void input();
void output();
};
class vat:public head
{
float vats;
public:
void vatcal();
void outputs();
void sum();
};
//******************************************************************
// INPUT FUNCTION
//******************************************************************
void head::input()
{
system("CLS");
cout<<"\nEnter number of items= ";
cin>>totalitems;
for(int i=0; i<totalitems; i++)
{
cout<<"\nEnter name of item "<<i+1<<": ";
cin>>Iname[i];
cout<<"Enter quantity: ";
cin>>Qty[i];
cout<<"Enter price of item "<<i+1<<": ";
cin>>price[i];
tprice[i]=Qty[i]*price[i];
}
}
//******************************************************************
// OUTPUT FUNCTION
//******************************************************************
void head::output()
{
int a;
ifstream infile("COUNT.TXT");
infile>>a;
ofstream outfile("COUNT.TXT");
a+=1;
outfile<<a;
outfile.close();
{ofstream outfile("HIS.TXT", ios::app);
outfile<<endl<<"Bill No.: "<<a<<endl;
outfile<<"------------------------------------------------------------------------"<<endl;
cout<<"\n";
cout<<"Name of Item\tQuantity Price Total Price\n";
for(int i=0;i<totalitems;i++)
{
outfile<<"Name: "<<Iname[i]<<" Qty: "<<Qty[i]<<" Price: "<<tprice[i]<<endl;
cout<<Iname[i]<<"\t\t"<<Qty[i]<<"\t "<<price[i]<<"\t "<<tprice[i]<<'\n';
}
outfile<<"------------------------------------------------------------------------"<<endl;
outfile.close();
}
}
//******************************************************************
// VAT CALCULATION
//******************************************************************
void vat::vatcal()
{
input();
for(int i=0;i<totalitems;i++)
{
if(price[i]<=100.00)
{
vatprice[i]=tprice[i]+(0.03*tprice[i]);
}
else
{
vatprice[i]=tprice[i]+(0.1*tprice[i]);
}
}
}
//******************************************************************
// VAT OUTPUTS
//******************************************************************
void vat::outputs()
{
output();
float cash=0,sum=0,qty=0,sumt=0;
for(int i=0;i<totalitems;i++)
{
sumt+=tprice[i];
sum+=vatprice[i];
qty+=Qty[i];
}
cout<<"\nTotal:";
cout<<"\n------------------------------------------------------------------------------";
cout<<"\n\tQuantity= "<<qty<<"\t\t Sum= "<<sumt<<"\tWith Vat:"<<sum;
cout<<"\n------------------------------------------------------------------------------";
pay:
cout<<"\n\n\t\t\t****PAYMENT SUMMARY****\n";
cout<<"\n\t\t\tTotal cash given: ";
cin>>cash;
if(cash>=sum)
cout<<"\n\t\t\tTotal cash repaid: "<<cash-sum<<'\n';
else
{ cout<<"\n\t\t\tCash given is less than total amount!!!";
goto pay;
}
}
//******************************************************************
// PROTECTION PASSWORD
//******************************************************************
int passwords()
{
char p1,p2,p3;
cout<<"\n\n\n\n\n\n\t\t\tENTER THE PASSWORD: "; //Pass : 000
cin>>p1;
cout<<"*";
cin>>p2;
cout<<"*";
cin>>p3;
cout<<"*";
if ((p1=='s'||p1=='S')&&(p2=='i'||p2=='I')&&(p3=='d'||p3=='D'))
return 1;
else
return 0;
}
// END of Password.
//****************************************************************
// THE MAIN FUNCTION OF PROGRAM
//****************************************************************
int main()
{
vat obj;
char opt, ch;
int a=1;
ifstream fin;
a==passwords();
if(!a)
{
for(int i=0;i<2;i++)
{
cout<<"\nWrong password try once more\n";
if(passwords())
{
goto last;
}
else
{
cout<<"\n\n\t\t\t all attempts failed.....";
cout<<"\n\n\n\t\t\t see you.................. ";
exit(0);
}
}
cout<<"\t\t\t sorry all attempts failed............. \n \t\t\tinactive";
}
else{
last:;
do{
start:
system("PAUSE");
system("CLS");
cout<<"\n\n\t\t\t------------------------------";
cout<<"\n\t\t\tShop Billing Management System";
cout<<"\n\t\t\t------------------------------";
cout<<"\n\n\t\t\tWhat you want to do?";
cout<<"\n\t\t\t1.\tTo enter new entry\n\t\t\t2.\tTo view previous entries\n\t\t\t3.\tExit\n";
cout<<"\n\nEnter your option: ";
cin>>opt;
switch(opt)
{
case'1':
obj.vatcal();
obj.outputs();
goto start;
case'2':
fin.open("HIS.TXT", ios::in);
while(fin.get(ch))
{
cout<<ch;
}
fin.close();
goto start;
case'3':
exit(0);
default:
cout<<"\a";
}
}while(opt!=3);
}
return 0;
}