-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex02.cpp
More file actions
50 lines (45 loc) · 1.05 KB
/
Copy pathex02.cpp
File metadata and controls
50 lines (45 loc) · 1.05 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
#include <iostream>
using namespace std;
const char ESC = 27;
const double COST = 0.50;
class tollBooth {
private:
unsigned int carsCount;
double totalCash;
public:
tollBooth() : carsCount(0), totalCash(0.0) {
}
void payingCar() {
++carsCount;
totalCash += COST;
}
void nopayCar() {
++carsCount;
}
void display()const {
cout << "\nЧисло машин: " << carsCount;
cout << "\nСуммарная выручка в центах: " << totalCash;
}
};
int main() {
tollBooth tb;
char ch = '0';
cout << "Нажмите \n1 - для машины с оплатой проезда"
<< "\n2 - для машины без оплаты проезда"
<< "\nEsc - чтобы выйти" << endl;
while (ch != ESC) {
cin >> ch;
if (ch == '1') {
tb.payingCar();
} else if (ch == '2') {
tb.nopayCar();
} else if (ch == ESC) {
break;
} else {
cout << "Неверный ввод" << endl;
break;
}
}
tb.display();
return 0;
}