-
Notifications
You must be signed in to change notification settings - Fork 0
/
oep-f(function_).cpp
263 lines (259 loc) · 5.77 KB
/
oep-f(function_).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
#include<iostream>
#include<stdlib.h>
#include<fstream>
#include<string.h>
#include<conio.h>
using namespace std;
float count(double total,int type)
{
double a,b,c,tax;
if(type==1)
{
if(total>250000&&total<=500000) //250001-500000
{a=total-250000;
tax=(a*0.1);}
if(total>500000&&total<1000000) //500001-1000000
{a=25000;
b=(total-500000);
tax=(a+b*0.2);}
if(total>1000000) //1000001-*
{a=25000;
b=100000;
c=total-1000000;
tax=(a+b+c*0.3);}
}
if(type==2)
{
if(total>300000&&total<=500000) //300001-500000
{a=total-300000;
tax=(a*0.1);}
if(total>500000&&total<1000000) //500001-1000000
{a=20000;
b=total-500000;
tax=(a+b*0.2);}
if(total>1000000) //1000001-*
{a=20000;
b=100000;
c=(total-1000000);
tax=(a+b+c*0.3);}
}
if(type==3)
{
if(total>250000&&total<=500000) //250001-500000
{a=0;
tax=(a*0.1);}
if(total>500000&&total<1000000) //500001-1000000
{a=0;
b=total-500000;
tax=(a+b*0.2);}
if(total>1000000) //1000001-*
{a=0;
b=100000;
c=total-1000000;
tax=(a+b+c*0.3);}
}
return tax;
}
void admin_enter()
{
ifstream fin;
ofstream fout;
int pn=0,age;
char name[20];
float fix,total=0;
fin.open("it1.txt",ios::app);
while(fin)
{
fin>>pn>>name>>age;
}
fin.close();
pn=pn+1;
cout<<"\nenter name";cin>>name;
cout<<"\nenter age:";cin>>age;
cout<<"\nnew customer pancard no is:"<<pn<<endl;
fout.open("it1.txt",ios::app);
fout<<pn<<"\t"<<name<<"\t"<<age<<endl;
fout.close();
}
void user_enter()
{
ofstream fout;
ifstream fin;
int pn1,pn,ans,age,age1,type;
char name1[20],name[20];
float nfix=0,fix,tax;
double total;
cout<<"\nenter pancard number:";cin>>pn1;
fin.open("it1.txt"); // checking record
while(fin)
{
fin>>pn>>name>>age;
if(pn1==pn)
{
age1=age;
strcpy(name1,name);
cout<<"\nyour record found with\t"<<name<<"\tname.\t";
break;
}
}
fin.close();
if(pn1!=pn)
{ cout<<"\nsorry your record not found enter proper pancard no!!!\n";
return;
}
cout<<"\nenter income(fix _monthly):";cin>>fix;
cout<<"\nany other non-fix income yearly ?(1/0):";cin>>ans;
if(ans!=0)
{cout<<"\nenter total amount of year(taxable):";cin>>nfix;
}
cout<<"\nthnx for enter your income\n";
if(age1<60&&age1>0) //type give 1.individual(m/f) 2.senior 3.super senior
type=1;
if(age1>=60&&age1<80)
type=2;
if(age1>=80)
type=3;
total=(fix*12)+nfix; //total count
if(total>250001)
{
tax=count(total,type); //tax count using function
cout<<"\ntotal:"<<total<<"\ttax:"<<tax;
}
else
{cout<<"\nyou are free from tax pay!!!!";
tax=0;}
fout.open("it2.txt",ios::app); //*
fout<<pn<<"\t"<<name<<"\t"<<total<<"\t"<<age<<"\t"<<tax<<endl; //*
fout.close();
}
void admin()
{
int pn,age;
double total,tax;
char name[20];
ifstream fin;
fin.open("it2.txt");
while(fin>>pn>>name>>total>>age>>tax)
{
cout<<"\npancard:"<<pn<<"\tname:"<<name<<"\tTotal income:"<<total<<"\tage:"<<age<<"\tTax:"<<tax<<endl;
}
fin.close();
}
void user()
{
int pn,flag=0,age,pn1;
double total,tax;
char name[20];
cout<<"\nenter pancard no:";
cin>>pn1;
ifstream fin;
fin.open("it2.txt");
while(fin>>pn>>name>>total>>age>>tax)
{
if(pn1==pn)
cout<<"\npancard:"<<pn<<"\tname"<<name<<"\tTotal income:"<<total<<"\tage:"<<age<<"\tTax:"<<tax<<endl;flag=1;
}
if(flag==0)
cout<<"\nsorry not found your record";
fin.close();
}
void check()
{
int ch,cn=1,k=0;
char pass[9],pass1[9],ch1;
pass[0]='a';
strcpy(pass,"check123");
do{
cout<<"\nenter right 1.admin 2.user 3.return";
cin>>ch;
switch(ch)
{
case 1:if(pass[0]=='a'||strcmp(pass,pass1))
{cout<<"\tenter password:";
ch1=getch();
cout<<"*";
do
{
pass1[k]=ch1;
k++;
ch1=getch();
cout<<"*";
}while(ch1!=13);
pass1[k]='\0';
}
if(!strcmp(pass1,pass))
admin();
else
cout<<"\nsorry wrong password:";
break;
case 2:user();
break;
case 3:return;
default:cout<<"enter proper choice";
break;
}
cout<<"continue checking data?(1/0):";
cin>>cn;
}while(cn==1);
}
void enterdata()
{
char pass[9],pass1[9],ch1;
pass[0]='a';
strcpy(pass,"enter123"); //password
int ch,cn=1,k=0;
do{
cout<<"enter right 1.admin 2.user 3.return";
cin>>ch;
switch(ch)
{
case 1:if(pass[0]=='a'||strcmp(pass,pass1))
{
cout<<"enter password:";
ch1=getch();
cout<<"*";
do
{
pass1[k]=ch1;
k++;
ch1=getch();
cout<<"*";
}while(ch1!=13);
pass1[k]='\0';
//cin>>pass1;
}
if(!strcmp(pass1,pass))
admin_enter();
else cout<<"sorry wrong password:";
break;
case 2:user_enter();
break;
case 3:return;
default:cout<<"enter proper choice";
break;
}
cout<<"continue entering data?(1/0):";
cin>>cn;
}while(cn==1);
}
int main()
{
int ch;
do{
cout<<"\nwhat you want:1.check 2.enterdata 3.exit";
cin>>ch;
switch(ch)
{
case 1:check();
break;
case 2:enterdata();
break;
case 3:exit(0);
break;
default:cout<<"enter proper choice!";
break;
}
cout<<"continue?(1/0)";cin>>ch;
}while(ch==1);
return 0;
}