You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/*Exercise #1: Construct for loops that accomplish the following tasks:
2
+
a. Print the numbers 0 - 20, one number per line.
3
+
b. Print only the ODD values from 3 - 29, one number per line.
4
+
c. Print the EVEN numbers 12 to -14 in descending order, one number per line.
5
+
d. Challenge - Print the numbers 50 - 20 in descending order, but only if the numbers are multiples of 3. (Your code should work even if you replace 50 or 20 with other numbers). */
6
+
7
+
8
+
9
+
10
+
/*Exercise #2:
11
+
Initialize two variables to hold the string “LaunchCode” and the array [1, 5, ‘LC101’, ‘blue’, 42].
12
+
13
+
14
+
Construct ``for`` loops to accomplish the following tasks:
15
+
a. Print each element of the array to a new line.
16
+
b. Print each character of the string - in reverse order - to a new line. */
17
+
18
+
19
+
20
+
21
+
22
+
/*Exercise #3:Construct a for loop that sorts the array [2, 3, 13, 18, -5, 38, -10, 11, 0, 104] into two new arrays:
23
+
a. One array contains the even numbers, and the other holds the odds.
//Define three variables for the LaunchCode shuttle - one for the starting fuel level, another for the number of astronauts aboard, and the third for the altitude the shuttle reaches.
2
+
3
+
4
+
5
+
6
+
7
+
/*Exercise #4: Construct while loops to do the following:
8
+
a. Query the user for the starting fuel level. Validate that the user enters a positive, integer value greater than 5000 but less than 30000. */
9
+
10
+
11
+
12
+
13
+
14
+
//b. Use a second loop to query the user for the number of astronauts (up to a maximum of 7). Validate the entry.
15
+
16
+
17
+
18
+
19
+
//c. Use a final loop to monitor the fuel status and the altitude of the shuttle. Each iteration, decrease the fuel level by 100 units for each astronaut aboard. Also, increase the altitude by 50 kilometers.
20
+
21
+
22
+
23
+
/*Exercise #5: Output the result with the phrase, “The shuttle gained an altitude of ___ km.”
24
+
25
+
If the altitude is 2000 km or higher, add “Orbit achieved!” Otherwise add, “Failed to reach orbit.”*/
0 commit comments