In: Math
The table below shows performance data for 100 flights between cities A - G for some airline, including: date, flight #, origin, destination, # passengers flown (load), and tardiness (late, in hours).
write a VBA code (N=10000) to simulate the following:
1. (I7): number of flights which were late for at least 0.75 hrs.
2. (I10) average load of flights originated from C with load exceeding 250.
3. (I13): smallest tardiness of flights from B to E between 9/1/18 and 9/3/18.
4. (I16): total load of flights flown from A to C, D, and E on 9/4/18.
5. (I19): the flight # of the flight with the maximal load among all flights from A to G with tardiness less than 0.6 hrs.
Date | Flight # | From | To | Load | Late |
09/01/18 | 7136 | C | A | 258 | 0.33 |
09/01/18 | 2770 | G | E | 179 | 0.50 |
09/01/18 | 2368 | A | B | 203 | 0.82 |
09/01/18 | 6690 | G | F | 189 | 0.96 |
09/01/18 | 7553 | A | E | 219 | 0.31 |
09/01/18 | 8323 | G | A | 246 | 0.80 |
09/01/18 | 7381 | D | C | 205 | 0.95 |
09/01/18 | 9008 | B | C | 281 | 0.52 |
09/01/18 | 8664 | A | G | 214 | 0.48 |
09/01/18 | 2826 | G | E | 171 | 0.62 |
09/01/18 | 6641 | C | E | 245 | 0.62 |
09/01/18 | 5402 | A | F | 194 | 0.06 |
09/01/18 | 3184 | A | G | 234 | 0.58 |
09/01/18 | 6806 | B | A | 257 | 0.46 |
09/01/18 | 9117 | D | C | 295 | 0.15 |
09/01/18 | 1259 | E | G | 283 | 0.54 |
09/01/18 | 5543 | B | E | 305 | 0.92 |
09/02/18 | 8008 | A | D | 319 | 0.39 |
09/02/18 | 8556 | A | B | 214 | 0.67 |
09/02/18 | 7559 | D | F | 285 | 0.08 |
09/02/18 | 8068 | C | B | 245 | 0.67 |
09/02/18 | 4717 | E | C | 286 | 0.71 |
09/02/18 | 6325 | F | B | 190 | 0.77 |
09/02/18 | 7037 | A | F | 259 | 0.73 |
09/02/18 | 5623 | D | C | 268 | 0.10 |
09/02/18 | 5431 | F | C | 302 | 0.90 |
09/02/18 | 3347 | C | G | 220 | 0.46 |
09/02/18 | 6860 | F | E | 224 | 0.96 |
09/02/18 | 1640 | C | D | 221 | 0.57 |
09/02/18 | 4486 | D | G | 206 | 0.06 |
09/02/18 | 9696 | A | G | 314 | 0.12 |
09/02/18 | 8081 | G | E | 270 | 0.46 |
09/02/18 | 9974 | G | E | 219 | 0.44 |
09/02/18 | 9724 | B | C | 245 | 0.20 |
09/02/18 | 3443 | B | E | 174 | 0.66 |
09/02/18 | 7582 | B | E | 218 | 0.27 |
09/03/18 | 2634 | G | E | 246 | 0.17 |
09/03/18 | 2617 | B | D | 172 | 0.08 |
09/03/18 | 7589 | E | D | 231 | 0.74 |
09/03/18 | 7545 | D | B | 226 | 0.72 |
09/03/18 | 8667 | E | B | 256 | 0.34 |
09/03/18 | 6576 | B | F | 199 | 0.07 |
09/03/18 | 8485 | C | E | 242 | 0.19 |
09/03/18 | 4958 | D | F | 281 | 0.17 |
09/03/18 | 8681 | F | G | 263 | 0.19 |
09/03/18 | 6224 | C | F | 281 | 0.97 |
09/03/18 | 6110 | B | D | 178 | 0.52 |
09/03/18 | 5971 | D | A | 188 | 0.11 |
09/03/18 | 5822 | B | A | 184 | 0.54 |
09/03/18 | 2075 | D | A | 242 | 0.62 |
09/03/18 | 9603 | A | E | 255 | 0.84 |
09/03/18 | 4909 | D | G | 252 | 0.51 |
09/03/18 | 4495 | A | G | 308 | 0.05 |
09/03/18 | 2861 | D | A | 316 | 0.20 |
09/03/18 | 8728 | A | F | 177 | 0.74 |
09/03/18 | 1327 | B | G | 216 | 0.76 |
09/04/18 | 9191 | A | D | 235 | 0.30 |
09/04/18 | 9239 | E | C | 235 | 0.72 |
09/04/18 | 5160 | E | F | 294 | 0.23 |
09/04/18 | 6930 | E | D | 227 | 0.52 |
09/04/18 | 9500 | F | E | 228 | 0.47 |
09/04/18 | 9861 | D | B | 248 | 0.92 |
09/04/18 | 5956 | D | A | 183 | 0.36 |
09/04/18 | 9071 | A | D | 267 | 0.53 |
09/04/18 | 7290 | E | G | 197 | 0.69 |
09/04/18 | 9086 | A | C | 310 | 0.08 |
09/04/18 | 5870 | D | B | 285 | 0.99 |
09/04/18 | 9595 | B | A | 231 | 0.56 |
09/04/18 | 9609 | D | C | 308 | 0.54 |
09/04/18 | 3446 | C | B | 288 | 0.27 |
09/04/18 | 9011 | G | B | 228 | 0.80 |
09/04/18 | 8651 | G | D | 225 | 0.87 |
09/04/18 | 2771 | F | G | 177 | 0.39 |
09/04/18 | 1360 | B | A | 231 | 0.33 |
09/04/18 | 7293 | G | F | 214 | 0.11 |
09/04/18 | 1412 | G | C | 256 | 0.62 |
09/04/18 | 2659 | A | B | 233 | 0.59 |
09/04/18 | 2847 | E | F | 182 | 0.47 |
09/04/18 | 4691 | D | E | 211 | 0.23 |
09/04/18 | 3392 | E | A | 232 | 0.48 |
09/04/18 | 3245 | C | A | 213 | 0.97 |
09/04/18 | 2691 | E | A | 248 | 0.07 |
09/04/18 | 9582 | G | B | 227 | 0.89 |
09/04/18 | 1591 | G | B | 280 | 0.25 |
09/05/18 | 5674 | B | G | 313 | 0.81 |
09/05/18 | 8560 | E | G | 288 | 0.09 |
09/05/18 | 1428 | D | F | 264 | 0.64 |
09/05/18 | 4483 | C | E | 221 | 0.73 |
09/05/18 | 3652 | G | A | 201 | 0.46 |
09/05/18 | 3474 | A | C | 206 | 0.92 |
09/05/18 | 8309 | F | C | 227 | 0.74 |
09/05/18 | 8774 | B | A | 209 | 0.65 |
09/05/18 | 2887 | A | D | 267 | 0.02 |
09/05/18 | 3499 | D | E | 183 | 0.33 |
09/05/18 | 8134 | C | A | 264 | 1.00 |
09/05/18 | 8516 | E | D | 315 | 0.83 |
09/05/18 | 7388 | C | B | 251 | 0.92 |
09/05/18 | 9037 | E | C | 319 | 0.45 |
09/05/18 | 1120 | E | C | 274 | 0.40 |
09/05/18 | 5919 | B | F | 254 | 0.65 |
please find the answer using ms-excel sort tools in Data Tab,
1. (I7): number of flights which were late for at least 0.75 hrs.
answer: 21
s.n. | Date | Flight # | From | To | Load | Late |
1 | 9/3/2018 | 1327 | B | G | 216 | 0.76 |
2 | 9/2/2018 | 6325 | F | B | 190 | 0.77 |
3 | 9/1/2018 | 8323 | G | A | 246 | 0.8 |
4 | 9/4/2018 | 9011 | G | B | 228 | 0.8 |
5 | 9/5/2018 | 5674 | B | G | 313 | 0.81 |
6 | 9/1/2018 | 2368 | A | B | 203 | 0.82 |
7 | 9/5/2018 | 8516 | E | D | 315 | 0.83 |
8 | 9/3/2018 | 9603 | A | E | 255 | 0.84 |
9 | 9/4/2018 | 8651 | G | D | 225 | 0.87 |
10 | 9/4/2018 | 9582 | G | B | 227 | 0.89 |
11 | 9/2/2018 | 5431 | F | C | 302 | 0.9 |
12 | 9/5/2018 | 3474 | A | C | 206 | 0.92 |
13 | 9/1/2018 | 5543 | B | E | 305 | 0.92 |
14 | 9/5/2018 | 7388 | C | B | 251 | 0.92 |
15 | 9/4/2018 | 9861 | D | B | 248 | 0.92 |
16 | 9/1/2018 | 7381 | D | C | 205 | 0.95 |
17 | 9/2/2018 | 6860 | F | E | 224 | 0.96 |
18 | 9/1/2018 | 6690 | G | F | 189 | 0.96 |
19 | 9/3/2018 | 6224 | C | F | 281 | 0.97 |
20 | 9/4/2018 | 3245 | C | A | 213 | 0.97 |
21 | 9/4/2018 | 5870 | D | B | 285 | 0.99 |
2. (I10) average load of flights originated from C with load exceeding 250.
answer:5
From | To | Load |
C | A | 213 |
C | G | 220 |
C | D | 221 |
C | E | 221 |
C | E | 242 |
C | E | 245 |
C | B | 245 |
C | B | 251 |
C | A | 258 |
C | A | 264 |
C | F | 281 |
C | B | 288 |
3. (I13): smallest tardiness of flights from B to E between 9/1/18 and 9/3/18.
answer: 0.27
Date | Flight # | From | To | Load | Late |
9/1/2018 | 6806 | B | A | 257 | 0.46 |
9/3/2018 | 5822 | B | A | 184 | 0.54 |
9/1/2018 | 9008 | B | C | 281 | 0.52 |
9/2/2018 | 9724 | B | C | 245 | 0.2 |
9/3/2018 | 2617 | B | D | 172 | 0.08 |
9/3/2018 | 6110 | B | D | 178 | 0.52 |
9/1/2018 | 5543 | B | E | 305 | 0.92 |
9/2/2018 | 7582 | B | E | 218 | 0.27 |
9/2/2018 | 3443 | B | E | 174 | 0.66 |
9/3/2018 | 6576 | B | F | 199 | 0.07 |
9/3/2018 | 1327 | B | G | 216 | 0.76 |
4. (I16): total load of flights flown from A to C, D, and E on 9/4/18.
Answer=310+235+267=812
Date | Flight # | From | To | Load | Late |
9/4/2018 | 9086 | A | C | 310 | 0.08 |
9/4/2018 | 9191 | A | D | 235 | 0.3 |
9/4/2018 | 9071 | A | D | 267 | 0.53 |
5. (I19): the flight # of the flight with the maximal load among all flights from A to G with tardiness less than 0.6 hrs.
answer:314
Date | Flight # | From | To | Load | Late |
9/1/2018 | 8664 | A | G | 214 | 0.48 |
9/1/2018 | 3184 | A | G | 234 | 0.58 |
9/2/2018 | 9696 | A | G | 314 | 0.12 |
9/3/2018 | 4495 | A | G | 308 | 0.05 |