@@ -2,22 +2,36 @@ let engineIndicatorLight = 'red blinking';
2
2
let fuelLevel = 21000 ;
3
3
let engineTemperature = 1200 ;
4
4
5
- /* 5) Implement the following checks using if/else if/else statements:
5
+ // 5) Implement the following checks using if/else if/else statements:
6
6
7
- a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
7
+ // a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
8
8
9
- b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
9
+ // b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
10
10
11
- c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
11
+ // c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
12
12
13
- d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
13
+ // d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
14
14
15
- e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
15
+ // e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
16
16
17
- f) Otherwise, print "Fuel and engine status pending..." */
17
+ // f) Otherwise, print "Fuel and engine status pending..."
18
18
19
19
// Code 5a - 5f here:
20
20
21
+ if ( fuelLevel > 20000 && engineTemperature <= 2500 ) {
22
+ console . log ( "Full tank. Engines good." ) ;
23
+ } else if ( fuelLevel > 10000 && engineTemperature <= 2500 ) {
24
+ console . log ( "Fuel level above 50%. Engines good." ) ;
25
+ } else if ( fuelLevel > 5000 && engineTemperature <= 2500 ) {
26
+ console . log ( "Fuel level above 25%. Engines good." ) ;
27
+ } else if ( fuelLevel <= 5000 || engineTemperature > 2500 ) {
28
+ console . log ( "Check fuel level. Engines running hot." ) ;
29
+ } else if ( fuelLevel < 1000 || engineTemperature > 3500 || engineIndicatorLight === "red blinking" ) {
30
+ console . log ( "ENGINE FAILURE IMMINENT!" ) ;
31
+ } else {
32
+ console . log ( "Fuel and engine status pending…" ) ;
33
+ }
34
+
21
35
// 6) a) Create the variable commandOverride, and set it to be true or false. If commandOverride is false, then the shuttle should only launch if the fuel and engine check are OK. If commandOverride is true, then the shuttle will launch regardless of the fuel and engine status.
22
36
23
37
/* 6) b) Code the following if/else check:
0 commit comments