-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy path5.cpp
53 lines (53 loc) · 918 Bytes
/
5.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{
private:
unsigned int cars_no;
double total;
public:
void init()
{
cars_no = 0;
total = 0;
}
void car()
{
cars_no++;
total = total + 0.50;
}
void nonpaycar()
{
cars_no++;
}
void display()
{
cout << "Total Cars = " << cars_no << endl;
cout << "Total Cash = " << total << " dollars" << endl;
}
};
int main()
{
cout << "1. Paying Car" << endl;
cout << "2. Non Paying Car" << endl;
cout << "3. Escape" << endl;
tollbooth day1;
day1.init();
while(1)
{
int a;
cin >> a;
if(a==1)
{
day1.car();
}
else if(a==2)
{
day1.nonpaycar();
}
else if(a==3)
{
day1.display();
exit(1);
}
}
}