-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnestedLogic.cpp
More file actions
52 lines (40 loc) · 1.06 KB
/
nestedLogic.cpp
File metadata and controls
52 lines (40 loc) · 1.06 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
#include <iostream>
using namespace std;
int toFine (int dayRet, int monthRet, int yearRet, int dayExp, int monthExp, int yearExp) {
int typeFine, fine, monthsLate, daysLate;
if (yearRet > yearExp) {
typeFine = 10000;
} else if (monthRet > monthExp) {
typeFine = 500;
monthsLate = monthRet - monthExp;
} else if (dayRet > dayExp){
typeFine = 15;
daysLate = dayRet - dayExp;
}
switch (typeFine) {
case 10000: fine = typeFine;
break;
case 500: fine = typeFine * monthsLate;
break;
case 15: fine = typeFine * daysLate;
break;
default: fine = 0;
break;
}
return fine;
}
int main() {
int fine;
int dayRet, dayExp;
int monthRet, monthExp;
int yearRet, yearExp;
cin >> dayRet;
cin >> monthRet;
cin >> yearRet;
cin >> dayExp;
cin >> monthExp;
cin >> yearExp;
fine = toFine(dayRet, monthRet, yearRet, dayExp, monthExp, yearExp);
cout << fine;
return 0;
}