-
Notifications
You must be signed in to change notification settings - Fork 0
/
Waste Management with function.fprg
294 lines (294 loc) · 21.8 KB
/
Waste Management with function.fprg
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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
<?xml version="1.0"?>
<flowgorithm fileversion="2.11">
<attributes>
<attribute name="name" value=""/>
<attribute name="authors" value="ELCOT"/>
<attribute name="about" value=""/>
<attribute name="saved" value="2021-05-11 12:35:52 PM"/>
<attribute name="created" value="RUxDT1Q7TEVOT1ZPOzIwMjEtMDEtMDc7MDY6Mzk6NTQgUE07MjEyNg=="/>
<attribute name="edited" value="RUxDT1Q7TEVOT1ZPOzIwMjEtMDItMDM7MDk6MjM6NDEgUE07MjtFTENPVDtMRU5PVk87MjAyMS0wMS0wNzswNjozOTo1NCBQTTtXYXN0ZSBNYW5hZ2VtZW50LmZwcmc7NjUxNA=="/>
<attribute name="edited" value="RUxDT1Q7TEVOT1ZPOzIwMjEtMDItMDY7MDk6MDA6MzMgUE07Mjg2OzIzMzM="/>
<attribute name="edited" value="TW9oYW47TVNJOzIwMjEtMDUtMTE7MTI6MzU6NTIgUE07MjsyMTE1"/>
</attributes>
<function name="Main" type="None" variable="">
<parameters/>
<body>
<declare name="areas, month, numofdays, pastday, presentday, b, c, d, e, f, daysd, daysp, dayse, totaldaysd, totaldaysp, totaldayse, vtotalnumofhouses, costofdeg, costofplast, costofelect, choice, continuezero, continueone, continuetwo" type="Integer" array="False" size=""/>
<declare name="totaldegwaste, totalplastwaste, totalelectwaste, degwastepercent, plastwastepercent, electwastepercent, totalearning" type="Real" array="False" size=""/>
<declare name="numofhouses, s" type="Integer" array="True" size="100"/>
<declare name="degwaste, plastwaste, electwaste, degwasteperhouse, plastwasteperhouse, electwasteperhouse, totalwasteperhouse, avgdegwaste, avgplastwaste, avgelectwaste, totalwasteqfour, costdegwasteperhouse, costplastwasteperhouse, costelectwasteperhouse, costperhouse, lowest" type="Real" array="True" size="1000"/>
<declare name="g" type="String" array="False" size=""/>
<output expression=""Enter num of areas:"" newline="True"/>
<input variable="areas"/>
<call expression="areas(numofhouses,areas)"/>
<do expression="continuetwo=1">
<assign variable="month" expression="12"/>
<assign variable="continueone" expression="1"/>
<while expression="month>0&&continueone=1">
<output expression=""Enter number of days in this month: "" newline="True"/>
<input variable="numofdays"/>
<assign variable="presentday" expression="0"/>
<assign variable="pastday" expression="0"/>
<assign variable="d" expression="0"/>
<assign variable="e" expression="0"/>
<assign variable="f" expression="0"/>
<assign variable="vtotalnumofhouses" expression="0"/>
<for variable="b" start="0" end="areas-1" direction="inc" step="1">
<assign variable="vtotalnumofhouses" expression="vtotalnumofhouses+numofhouses[b]"/>
</for>
<do expression="numofdays!=presentday">
<assign variable="presentday" expression="presentday+1"/>
<output expression=""Day "&presentday" newline="True"/>
<if expression="presentday=pastday+1">
<then>
<assign variable="g" expression=""degradable""/>
<call expression="dailywaste(degwaste,numofhouses,areas,d,g)"/>
<assign variable="d" expression="d+vtotalnumofhouses"/>
</then>
<else>
<if expression="presentday=pastday+2">
<then>
<assign variable="g" expression=""plastic""/>
<call expression="dailywaste(plastwaste,numofhouses,areas,e,g)"/>
<assign variable="e" expression="e+vtotalnumofhouses"/>
</then>
<else>
<if expression="presentday=pastday+3">
<then>
<assign variable="g" expression=""electronic""/>
<call expression="dailywaste(electwaste,numofhouses,areas,f,g)"/>
<assign variable="f" expression="f+vtotalnumofhouses"/>
<assign variable="pastday" expression="presentday"/>
</then>
<else/>
</if>
</else>
</if>
</else>
</if>
</do>
<output expression=""You have collected monthly data :)"" newline="True"/>
<if expression="numofdays=29">
<then>
<assign variable="daysd" expression="10"/>
<assign variable="daysp" expression="10"/>
<assign variable="dayse" expression="9"/>
</then>
<else>
<assign variable="daysd" expression="(numofdays/3)+(numofdays%3)"/>
<assign variable="daysp" expression="numofdays/3"/>
<assign variable="dayse" expression="numofdays/3"/>
</else>
</if>
<assign variable="costofdeg" expression="5"/>
<assign variable="costofplast" expression="10"/>
<assign variable="costofelect" expression="15"/>
<assign variable="totaldaysd" expression="0"/>
<call expression="basictwo(vtotalnumofhouses,totaldaysd,degwaste,degwasteperhouse,costdegwasteperhouse,costofdeg,daysd)"/>
<assign variable="totaldaysp" expression="0"/>
<call expression="basictwo(vtotalnumofhouses,totaldaysp,plastwaste,plastwasteperhouse,costplastwasteperhouse,costofplast,daysp)"/>
<assign variable="totaldayse" expression="0"/>
<call expression="basictwo(vtotalnumofhouses,totaldayse,electwaste,electwasteperhouse,costelectwasteperhouse,costofelect,dayse)"/>
<comment text="Common loop of choice 1,4"/>
<for variable="b" start="0" end="vtotalnumofhouses-1" direction="inc" step="1">
<assign variable="totalwasteperhouse[b]" expression="degwasteperhouse[b]+plastwasteperhouse[b]+electwasteperhouse[b]"/>
<assign variable="costperhouse[b]" expression="costdegwasteperhouse[b]+costplastwasteperhouse[b]+costelectwasteperhouse[b]"/>
</for>
<comment text="Common loop of choice 2,3,4,5"/>
<assign variable="e" expression="0"/>
<call expression="twothreefourfive(areas,numofhouses,totalwasteqfour,avgdegwaste,degwasteperhouse,e)"/>
<assign variable="e" expression="1"/>
<call expression="twothreefourfive(areas,numofhouses,totalwasteqfour,avgplastwaste,plastwasteperhouse,e)"/>
<assign variable="e" expression="2"/>
<call expression="twothreefourfive(areas,numofhouses,totalwasteqfour,avgelectwaste,electwasteperhouse,e)"/>
<comment text="Common loop of choice 2,3,5"/>
<assign variable="s[0]" expression="0"/>
<assign variable="lowest[0]" expression="totalwasteperhouse[0]"/>
<call expression="twothreefive(totalwasteperhouse,costperhouse,vtotalnumofhouses,s,lowest)"/>
<do expression="continuezero=1">
<output expression=""You have collected monthly data"&tochar(13)& "Enter you choice:"&tochar(13)& "1 for statistics"&tochar(13)& "2 to know house and area number of house which gave less quantity of waste"&tochar(13)& "3 to know processing fee of each house and monthly earning for municipality"&tochar(13)& "4 to know percentage of waste from each category"&tochar(13)& "5 to know monthly expenses of a particular house"" newline="True"/>
<input variable="choice"/>
<if expression="choice=1">
<then>
<output expression=""Statistics:Average waste collection of this month"" newline="True"/>
<for variable="b" start="0" end="areas-1" direction="inc" step="1">
<output expression=""Area "&b+1" newline="True"/>
<output expression=""degradable waste : "&avgdegwaste[b]&" kg"" newline="True"/>
<output expression=""plastic waste : "&avgplastwaste[b]&" kg"" newline="True"/>
<output expression=""electronic waste : "&avgelectwaste[b]&" kg"" newline="True"/>
<output expression=""All wastes : "&(avgdegwaste[b]+avgplastwaste[b]+avgelectwaste[b])/3&" kg"" newline="True"/>
</for>
</then>
<else>
<if expression="choice=2">
<then>
<output expression=""The house number "&s[0]+1&" gave "&lowest[0]&" kg of waste which is least of all"" newline="True"/>
<output expression=""So the municipality decides to refund the processing fee of that house"" newline="True"/>
</then>
<else>
<if expression="choice=3">
<then>
<assign variable="d" expression="0"/>
<assign variable="totalearning" expression="0"/>
<output expression=""Processing fee of waste per house "" newline="True"/>
<for variable="b" start="0" end="areas-1" direction="inc" step="1">
<output expression=""Area "&b+1" newline="True"/>
<for variable="c" start="0" end="numofhouses[b]-1" direction="inc" step="1">
<output expression=""House number "&d+1&" : "&costperhouse[d]&" rupees"" newline="True"/>
<assign variable="totalearning" expression="totalearning+costperhouse[d]"/>
<assign variable="d" expression="d+1"/>
</for>
</for>
<output expression=""Total earning for municipality from all areas in this month"&" : "&totalearning&" rupees"" newline="True"/>
</then>
<else>
<if expression="choice=4">
<then>
<assign variable="degwastepercent" expression="totalwasteqfour[0]*100/(totalwasteqfour[0]+totalwasteqfour[1]+totalwasteqfour[2])"/>
<assign variable="plastwastepercent" expression="totalwasteqfour[1]*100/(totalwasteqfour[0]+totalwasteqfour[1]+totalwasteqfour[2])"/>
<assign variable="electwastepercent" expression="totalwasteqfour[2]*100/(totalwasteqfour[0]+totalwasteqfour[1]+totalwasteqfour[2])"/>
<output expression=""Percentage of wastes in all areas"&tochar(13)& "Degradable waste : "&degwastepercent&"%"&tochar(13)& "Plastic waste : "&plastwastepercent&"%"&tochar(13)& "Electronic waste : "&electwastepercent&"%"" newline="True"/>
</then>
<else>
<if expression="choice=5">
<then>
<output expression=""To know a particular house expenses"" newline="True"/>
<output expression=""Enter House num :"" newline="True"/>
<input variable="b"/>
<if expression="b<=vtotalnumofhouses">
<then>
<output expression=""Expenses of house number "&b&" : "&costperhouse[b-1]&" rupees"" newline="True"/>
</then>
<else>
<output expression=""Invalid House number !"" newline="True"/>
</else>
</if>
</then>
<else>
<output expression=""Invalid choice !"" newline="True"/>
</else>
</if>
</else>
</if>
</else>
</if>
</else>
</if>
</else>
</if>
<output expression=""Do you want to choose another option: "&tochar(13)& "Enter 1 to continue"&tochar(13)& "Enter 0 to stop"" newline="True"/>
<input variable="continuezero"/>
</do>
<output expression=""You have completed a month :)"&tochar(13)& "Do you want to continue: "&tochar(13)& "Enter 1 to continue"&tochar(13)& "Enter 0 to stop"" newline="True"/>
<input variable="continueone"/>
<assign variable="month" expression="month-1"/>
</while>
<output expression=""You have completed a year :) "&tochar(13)& "Do you want to continue:"&tochar(13)& "Enter 1 to continue"&tochar(13)& "Enter 0 to stop"" newline="True"/>
<input variable="continuetwo"/>
</do>
<output expression=""Thanks for using our program :)"" newline="True"/>
</body>
</function>
<function name="areas" type="None" variable="">
<parameters>
<parameter name="numofhouses" type="Integer" array="True"/>
<parameter name="areas" type="Integer" array="False"/>
</parameters>
<body>
<declare name="a" type="Integer" array="False" size=""/>
<for variable="a" start="0" end="areas-1" direction="inc" step="1">
<output expression=""Enter number of houses in area "&a+1&" : "" newline="True"/>
<input variable="numofhouses[a]"/>
</for>
</body>
</function>
<function name="basictwo" type="None" variable="">
<parameters>
<parameter name="vtotalnumofhouses" type="Integer" array="False"/>
<parameter name="totaldays" type="Integer" array="False"/>
<parameter name="waste" type="Real" array="True"/>
<parameter name="wasteperhouse" type="Real" array="True"/>
<parameter name="costwasteperhouse" type="Real" array="True"/>
<parameter name="cost" type="Integer" array="False"/>
<parameter name="days" type="Integer" array="False"/>
</parameters>
<body>
<declare name="b, c, vwaste" type="Integer" array="False" size=""/>
<assign variable="totaldays" expression="days*vtotalnumofhouses"/>
<for variable="b" start="0" end="vtotalnumofhouses-1" direction="inc" step="1">
<assign variable="vwaste" expression="0"/>
<for variable="c" start="0+b" end="totaldays-1" direction="inc" step="vtotalnumofhouses">
<assign variable="vwaste" expression="vwaste+waste[c]"/>
</for>
<assign variable="wasteperhouse[b]" expression="vwaste"/>
<assign variable="costwasteperhouse[b]" expression="vwaste*cost"/>
</for>
</body>
</function>
<function name="dailywaste" type="None" variable="">
<parameters>
<parameter name="waste" type="Real" array="True"/>
<parameter name="numofhouses" type="Integer" array="True"/>
<parameter name="areas" type="Integer" array="False"/>
<parameter name="d" type="Integer" array="False"/>
<parameter name="g" type="String" array="False"/>
</parameters>
<body>
<declare name="b, c" type="Integer" array="False" size=""/>
<for variable="b" start="0" end="areas-1" direction="inc" step="1">
<output expression=""Area "&b+1" newline="True"/>
<for variable="c" start="0" end="numofhouses[b]-1" direction="inc" step="1">
<output expression=""Enter weight of "&g&" waste in house "&c+1&" of this area: "" newline="True"/>
<input variable="waste[d]"/>
<assign variable="d" expression="d+1"/>
</for>
</for>
</body>
</function>
<function name="twothreefive" type="None" variable="">
<parameters>
<parameter name="totalwasteperhouse" type="Real" array="True"/>
<parameter name="costperhouse" type="Real" array="True"/>
<parameter name="vtotalnumofhouses" type="Integer" array="False"/>
<parameter name="s" type="Integer" array="True"/>
<parameter name="lowest" type="Real" array="True"/>
</parameters>
<body>
<declare name="b" type="Integer" array="False" size=""/>
<for variable="b" start="1" end="vtotalnumofhouses-1" direction="inc" step="1">
<if expression="lowest[0]>totalwasteperhouse[b]">
<then>
<assign variable="lowest[0]" expression="totalwasteperhouse[b]"/>
<assign variable="s[0]" expression="b"/>
</then>
<else/>
</if>
</for>
<assign variable="costperhouse[s[0]]" expression="0"/>
</body>
</function>
<function name="twothreefourfive" type="None" variable="">
<parameters>
<parameter name="areas" type="Integer" array="False"/>
<parameter name="numofhouses" type="Integer" array="True"/>
<parameter name="totalwasteqfour" type="Real" array="True"/>
<parameter name="avgwaste" type="Real" array="True"/>
<parameter name="wasteperhouse" type="Real" array="True"/>
<parameter name="e" type="Integer" array="False"/>
</parameters>
<body>
<declare name="b, c, d, totalwaste" type="Integer" array="False" size=""/>
<assign variable="d" expression="0"/>
<assign variable="totalwasteqfour[e]" expression="0"/>
<for variable="b" start="0" end="areas-1" direction="inc" step="1">
<assign variable="totalwaste" expression="0"/>
<for variable="c" start="0" end="numofhouses[b]-1" direction="inc" step="1">
<assign variable="totalwaste" expression="totalwaste+wasteperhouse[d]"/>
<assign variable="d" expression="d+1"/>
</for>
<assign variable="totalwasteqfour[e]" expression="totalwasteqfour[e]+totalwaste"/>
<assign variable="avgwaste[b]" expression="totalwaste/numofhouses[b]"/>
</for>
</body>
</function>
</flowgorithm>