Skip to content

Commit c550618

Browse files
Merge pull request LaunchCodeEducation#1 from LaunchCodeEducation/booleans-and-conditionals
Booleans and conditionals
2 parents 6c987db + db4a006 commit c550618

File tree

4 files changed

+71
-0
lines changed

4 files changed

+71
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Declare and initialize the variables for exercise 1 here:
2+
3+
// BEFORE running the code, predict what will be printed to the console by the following statements:
4+
5+
if (engineIndicatorLight === "green") {
6+
console.log("engines have started");
7+
} else if (engineIndicatorLight === "green blinking") {
8+
console.log("engines are preparing to start");
9+
} else {
10+
console.log("engines are off");
11+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
let engineIndicatorLight = "red blinking";
2+
let spaceSuitsOn = true;
3+
let shuttleCabinReady = true;
4+
let crewStatus = spaceSuitsOn && shuttleCabinReady;
5+
let computerStatusCode = 200;
6+
let shuttleSpeed = 15000;
7+
8+
// 3) Write conditional expressions to satisfy the following safety rules:
9+
10+
// a) If crewStatus is true, print "Crew Ready" else print "Crew Not Ready".
11+
12+
13+
// b) If computerStatusCode is 200, print "Please stand by. Computer is rebooting." Else if computerStatusCode is 400, print "Success! Computer online." Else print "ALERT: Computer offline!"
14+
15+
16+
// c) If shuttleSpeed is > 17,500, print "ALERT: Escape velocity reached!" Else if shuttleSpeed is < 8000, print "ALERT: Cannot maintain orbit!" Else print "Stable speed".
17+
18+
19+
// 4) PREDICT: Do the code blocks shown in the 'predict.txt' file produce the same result?
20+
21+
console.log(/* "Yes" or "No" */);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
let engineIndicatorLight = 'red blinking';
2+
let fuelLevel = 21000;
3+
let engineTemperature = 1200;
4+
5+
/* 5) Implement the following checks using if/else if/else statements:
6+
7+
a) If fuelLevel is above 20000 AND engineTemperature is at or below 2500, print "Full tank. Engines good."
8+
9+
b) If fuelLevel is above 10000 AND engineTemperature is at or below 2500, print "Fuel level above 50%. Engines good."
10+
11+
c) If fuelLevel is above 5000 AND engineTemperature is at or below 2500, print "Fuel level above 25%. Engines good."
12+
13+
d) If fuelLevel is at or below 5000 OR engineTemperature is above 2500, print "Check fuel level. Engines running hot."
14+
15+
e) If fuelLevel is below 1000 OR engineTemperature is above 3500 OR engineIndicatorLight is red blinking print "ENGINE FAILURE IMMINENT!"
16+
17+
f) Otherwise, print "Fuel and engine status pending..." */
18+
19+
// Code 5a - 5f here:
20+
21+
// 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+
23+
/* 6) b) Code the following if/else check:
24+
If fuelLevel is above 20000 AND engineIndicatorLight is NOT red blinking OR commandOverride is true print "Cleared to launch!" Else print "Launch scrubbed!" */
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Initialize Variables below
2+
3+
// add logic below to verify total number of astronauts for shuttle launch does not exceed 7
4+
5+
// add logic below to verify all astronauts are ready
6+
7+
// add logic below to verify the total mass does not exceed the maximum limit of 850000
8+
9+
// add logic below to verify the fuel temperature is within the appropriate range of -150 and -300
10+
11+
// add logic below to verify the fuel level is at 100%
12+
13+
// add logic below to verify the weather status is clear
14+
15+
// Verify shuttle launch can proceed based on above conditions

0 commit comments

Comments
 (0)