-
Notifications
You must be signed in to change notification settings - Fork 4
/
BarnCampReport.cbl
164 lines (143 loc) · 6.03 KB
/
BarnCampReport.cbl
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
identification division.
program-id. BarnCampReport is initial.
environment division.
input-output section.
file-control.
select optional AttendeesFile assign to AttendeesFileName
organization is indexed
access mode is dynamic
record key is AuthCode
file status is AttendeeStatus.
data division.
file section.
fd AttendeesFile is global.
copy DD-Attendee replacing Attendee by
==AttendeeRecord is global.
88 EndOfAttendeesFile value high-values==.
working-storage section.
01 AttendeeStatus pic x(2).
88 Successful value "00".
88 RecordExists value "22".
88 NoSuchRecord value "23".
01 HeadCounts.
02 ActualHeadCounts.
03 HeadCountWednesday pic 99 value zero.
03 HeadCountThursday pic 99 value zero.
03 HeadCountFriday pic 99 value zero.
03 HeadCountSaturday pic 99 value zero.
03 HeadCountSunday pic 99 value zero.
03 HeadCountMonday pic 99 value zero.
02 EstimatedHeadCounts.
03 EstimatedHeadCountWednesday pic 99 value zero.
03 EstimatedHeadCountThursday pic 99 value zero.
03 EstimatedHeadCountFriday pic 99 value zero.
03 EstimatedHeadCountSaturday pic 99 value zero.
03 EstimatedHeadCountSunday pic 99 value zero.
03 EstimatedHeadCountMonday pic 99 value zero.
01 TotalNightsCamping pic 999 value zero.
01 CostPerNight constant as 2.
01 TotalCampingCharge pic 999v99 value 0.00.
01 TotalPaid pic 9(4) value zero.
01 TotalToPay pic 9(4) value zero.
01 TotalIncome pic 9(4) value zero.
01 NumberOfAttendees pic 9(3) value zero.
01 AveragePaid pic 99v99 value zero.
01 IgnoredValue pic 9(4).
01 FigureOutput pic z,z99.99.
01 AttendeesFileName pic x(20) value spaces.
01 CommandLineArgumentCount pic 9 value zero.
procedure division.
accept CommandLineArgumentCount from argument-number
if CommandLineArgumentCount equal to 2 then
accept AttendeesFileName from argument-value
else
move "attendees.dat" to AttendeesFileName
end-if
display spaces
display "Special diet report"
display "==================="
move zeroes to AuthCode
start AttendeesFile key is greater than AuthCode
open input AttendeesFile
read AttendeesFile next record
at end set EndOfAttendeesFile to true
end-read
perform until EndOfAttendeesFile
if function length(function trim(Diet)) is greater than 5 then
display function trim(AttendeeName) " says '" function trim (Diet) "'"
end-if
if AttendeeArrived then
evaluate true
when ArrivalDayIsWednesday add 1 to HeadCountWednesday
when ArrivalDayIsThursday add 1 to HeadCountThursday
when ArrivalDayIsFriday add 1 to HeadCountFriday
when ArrivalDayIsSaturday add 1 to HeadCountSaturday
end-evaluate
if CanStayTillMonday then
add 1 to HeadCountMonday
end-if
end-if
if AttendeeComing or AttendeeArrived then
evaluate true
when ArrivalDayIsWednesday add 1 to EstimatedHeadCountWednesday
when ArrivalDayIsThursday add 1 to EstimatedHeadCountThursday
when ArrivalDayIsFriday add 1 to EstimatedHeadCountFriday
when ArrivalDayIsSaturday add 1 to EstimatedHeadCountSaturday
when CanStayTillMonday add 1 to HeadCountMonday
end-evaluate
end-if
if AttendeeComing or AttendeeArrived then
add 1 to NumberOfAttendees
end-if
evaluate true
when AttendeePaid add AmountPaid to TotalPaid
when AttendeeNotPaid add AmountToPay to TotalToPay
end-evaluate
read AttendeesFile next record
at end set EndOfAttendeesFile to true
end-read
end-perform
close AttendeesFile
add HeadCountWednesday to HeadCountThursday
add HeadCountThursday to HeadCountFriday
add HeadCountFriday to HeadCountSaturday
add HeadCountSaturday to HeadCountSunday
add EstimatedHeadCountWednesday to EstimatedHeadCountThursday
add EstimatedHeadCountThursday to EstimatedHeadCountFriday
add EstimatedHeadCountFriday to EstimatedHeadCountSaturday
add EstimatedHeadCountSaturday to EstimatedHeadCountSunday
display spaces
display "Attendance report"
display "================"
display " Act (Est)"
display "Wednesday: " HeadCountWednesday " (" EstimatedHeadCountWednesday ")"
display "Thursday: " HeadCountThursday " (" EstimatedHeadCountThursday ")"
display "Friday: " HeadCountFriday " (" EstimatedHeadCountFriday ")"
display "Saturday: " HeadCountSaturday " (" EstimatedHeadCountSaturday ")"
display "Sunday: " HeadCountSunday " (" EstimatedHeadCountSunday ")"
display "Monday: " HeadCountMonday " (" EstimatedHeadCountMonday ")"
display spaces
display "Camping report"
display "=============="
compute TotalNightsCamping = HeadCountWednesday + HeadCountThursday + HeadCountFriday + HeadCountSaturday + HeadCountMonday
multiply CostPerNight by TotalNightsCamping giving TotalCampingCharge
display "Nights camped: " TotalNightsCamping
display "Camping charge: " TotalCampingCharge
display spaces
display "Financial report"
display "================"
display spaces
move TotalPaid to FigureOutput
display "Total paid is: " FigureOutput
move TotalToPay to FigureOutput
display "Total to pay is: " FigureOutput
add TotalPaid to TotalToPay giving TotalIncome
move TotalIncome to FigureOutput
display "-------------------------"
display "Total income is: " FigureOutput
divide TotalIncome by NumberOfAttendees giving AveragePaid rounded mode is away-from-zero
display spaces
display "Average paid is: " AveragePaid
display spaces
exit program.
end program BarnCampReport.