forked from Ayush-chhabra/Hacktoberfest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ3.CPP
More file actions
72 lines (71 loc) · 1.32 KB
/
Q3.CPP
File metadata and controls
72 lines (71 loc) · 1.32 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
#include<iostream>
#include<stdio.h>
#include<conio.h>
struct electbill
{
int custno;
long int units;
float bill;
}c[30],d[1];
int input()
{
int k;
char ch;
for(int i=0;i<30;i++)
{
cout<<"\nEnter customer no: ";
cin>>c[i].custno;
cout<<"Enter no of units consumed: ";
cin>>c[i].units;
if(c[i].units<=100)
c[i].bill=c[i].units*0.40;
else if(c[i].units<=200)
c[i].bill=100*0.40+(c[i].units-100)*0.50;
else if(c[i].units<=300)
c[i].bill=100*0.40+100*0.50+(c[i].units-200)*0.75;
else if(c[i].units<=400)
c[i].bill=100*0.40+100*0.50+100*0.75+(c[i].units-300)*1;
else if(c[i].units<=1000)
c[i].bill=100*0.40+100*0.50+100*0.75+100*1+(c[i].units-400)*1.50;
cout<<"To enter more records press y: ";
cin>>ch;
if(ch=='y'||ch=='Y')
continue;
else
k=i;
break;
}
return k;
}
void output(int k)
{
int i,j;
for(i=0;i<k+1;i++)
{
for(j=0;j<k+1;j++)
{
if(c[i].custno<c[j].custno)
{
d[1]=c[i];
c[i]=c[j];
c[j]=d[1];
}
}
}
cout<<"\nCustomer Information:-";
for(i=0;i<k+1;i++)
{
cout<<"\n\nCustomer No= "<<c[i].custno;
cout<<"\nNo of units= "<<c[i].units;
cout<<"\nBill= "<<c[i].bill;
}
}
void main()
{
clrscr();
cout<<"Enter details of consumer:\n";
int b;
b=input();
output(b);
getch();
}