Professional Documents
Culture Documents
Project KM1024
Project KM1024
Considering the traffic parameters, construct a computer program to guide the driver to the
destination. A computer program will display some of the results as listed in the table after the
driver reaches the destination. The conditions before and during the journey begin as follows:
Conditions:
Initial fuel = 100 L
Fuel price = RM2.00 /L
Initial passengers = 10
Start time = 8:00 am
Refuelling 20 L for every 60km
Legend:
Distance (km)
+2
1.10
Toll (RM)
55
Speed (km/h)
Groups
Destination
Group
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
From
A
B
C
D
E
A
B
C
D
E
A
B
C
D
E
A
To
5
4
3
2
1
4
3
2
1
5
3
2
1
5
4
5
Fuel used
(L)
Total cost
(RM)
x
x
x
x
x
x
No of road
segments
x
x
x
x
x
x
x
Fuel
Balance
(L)
x
x
x
x
x
x
Results
Arrival Passengers
time
at
Destination
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
1
48 0.20
-1
1.60
20 0.23
21 0.25
0.70
+0
60
+2
0.90
0
55
65
20 0.24
+0
0.90
65
32 0.20
+2
21 0.25
0
25 0.24
+3
-1
1.60
65
21 0.25
17 0.20
20 0.21
0
-1
1.20
65
26 0.21
-1
0.80
-2
13 0.26
0.30
65
0.50
65
+2
25 0.25
+1
1.10
-1
-1
0
65
0.25
70
50
1.20
13 0.23
55
19 0.26
+2
0
24 0.25
50
60
0.50
60
+2
0.27
8
+1
+2
0.40
55
21 0.25
0
50
1.20
50
19 0.29
24
+2
1.50
1.60
+2
75
1.20
55
1.10
21 0.25
55
65
23 0.20
+2
24 0.28
+3
24 0.25
0.3
+2
+2
1.20
50
15 0.25
+0
26 0.21
50
18 0.27
0
70
17 0.24
+1
+2
45
18 0.28
+3
+2
35 0.22
55
50
B
C
1.30
70
-1
1.20
25 0.20
50
+2
23 0.24
26 0.25
-1
-1
29
60
1.00
+0
70
.22
21 0.25
1.20
65
-1
29 0.24
+2
0
17 0.22
55
-1
0.90
65
0.25
+0
60
0
0.90
65
24 0.20
+1
0
68
55
0
60
23 0.21
+3
0
70
29 0.23
+2
1.00
50
20 0.23
+2
75
Example :
To travel from A to 2, the driver will :
r1 is selected. then
choose r2 or r3 ?
if r2 is selected then r4 and r6 are selected. Choose r15 or r12?
If r15 is selected then r16 is selected. Display Total distance (km)/ Fuel used (litre)/Total Cost (RM). End Program.
if r3 is selected , choose r7 or r9?
If r7 is selected, then r8 is selected. Choose r12 or r13?
If r12 is selected, then r15 and r16 are selected. Display Total distance (km)/ Fuel used (litre)/Total Cost (RM). End Program.
If r13 is selected, then r14 and r16 are selected. Display Total distance (km)/ Fuel used (litre)/Total Cost (RM). End Program.
If r9 is selected, choose r10 or r??
If r10 is selected, choose r11 or r??
If r11 is selected then r8 is selected. Choose r12 or r13?
If r12 is selected, then r15 and r16 are selected. Display Total distance (km)/ Fuel used (litre)/Total Cost (RM). End Program.
If r13 is selected, then r14 and r16 are selected. Display Total distance (km)/ Fuel used (litre)/Total Cost (RM). End Program.
If r? Is selected ......
If r? Is selected, .....
...
...
...