-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathClass_TollBooth.cpp
53 lines (53 loc) · 1.07 KB
/
Class_TollBooth.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
#include<iostream>
using namespace std;
class TollBooth
{
unsigned int cars;
double cash;
public:
TollBooth()
{
cars=0;
cash=0;
}
void payingCars()
{
cars++;
cash+=0.5;
}
void nonPayCars()
{
cars++;
}
void display()
{
cout<<"Total no. of cars that passed are : "<<cars;
cout<<"\nTotal cash collected is : "<<cash;
}
};
int main()
{
TollBooth obj;
char c;
do
{
cout<<"'a'-Paying Car\n'b'-Non Paying Car\nESC-Display and exit\n";
cout<<"Enter your choice : ";
cin>>c;
switch (c)
{
case 'a':
obj.payingCars();
break;
case 'b':
obj.nonPayCars();
break;
case 27:
obj.display();
default:
cout<<"Invalid Choice.";
}
}
while(c!=27);
return 0;
}