-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBILLS.CPP
More file actions
61 lines (57 loc) · 973 Bytes
/
BILLS.CPP
File metadata and controls
61 lines (57 loc) · 973 Bytes
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
#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
struct elect
{
float bill;
float unit;
char name[15];
};
void main()
{
struct elect *p;
int i,n;
clrscr();
cout<<"How many users\n";
cin>>n;
p=new struct elect [n];
for(i=0;i<n;i++)
{
cout<<"\n enter user name , units consumed for user"<<(i+1)<<endl;
cin>>((p+i)->name);
cin>>((p+i)->unit);
}
for(i=0;i<n;i++)
{
if(((p+i)->unit)==0)
{
(p+i)->bill=50;
continue;
}
if((p+i)->unit<=100)
{
(p+i)->bill=(0.6)*((p+i)->unit);
}
if(((p+i)->unit)>100&&((p+i)->unit)<=300)
{
(p+i)->bill=(0.8)*((p+i)->unit);
}
if(((p+i)->unit)>300)
{
(p+i)->bill=(0.9)*((p+i)->unit);
}
if((p+i)->bill>300)
{
(p+i)->bill+=0.15*((p+i)->bill);
}
}
cout<<"NAME\t\tUNITS\t\tBILL\n";
for(i=0;i<n;i++)
{
cout<<endl<<(p+i)->name;
cout<<"\t\t"<<(p+i)->unit;
cout<<"\t\t"<<setprecision(4)<<(p+i)->bill;
}
delete [] p;
getch();
}