'F' → Fullscreen
Everything today goes in a new program named 1-16-nested.
How to read the code blocks. Each task's code block shows your whole program, from line 1, as it should look when that task is finished.
The green lines marked with a + are the ones you add or change for that task — everything else is already in your file. Do not type the + sign.
Where a block shows only comments, you write that code yourself. The comments stay in your file.
else.int crewSize = 1;int cargoMass = 300;
if (crewSize >= 2 && cargoMass < 500){ Console.WriteLine("LAUNCH APPROVED");}else{ if (crewSize < 2) { Console.WriteLine("DENIED: crew too small"); } else { Console.WriteLine("DENIED: cargo too heavy"); }}Random.Shared.Next(1, 7) gives a whole number from 1 to 6. The 7 is where it stops, not a face on the die.int crewSize = 1;int cargoMass = 300;
if (crewSize >= 2 && cargoMass < 500){ Console.WriteLine("LAUNCH APPROVED");}else{ if (crewSize < 2) { Console.WriteLine("DENIED: crew too small"); } else { Console.WriteLine("DENIED: cargo too heavy"); }}
Console.WriteLine();
int roll = Random.Shared.Next(1, 7);Console.WriteLine($"Solar flare check, rolled: {roll}");
if (roll >= 5){ Console.WriteLine("Flare detected.");}else{ Console.WriteLine("Skies clear.");}int crewSize = 1;int cargoMass = 300;
if (crewSize >= 2 && cargoMass < 500){ Console.WriteLine("LAUNCH APPROVED");}else{ if (crewSize < 2) { Console.WriteLine("DENIED: crew too small"); } else { Console.WriteLine("DENIED: cargo too heavy"); }}
Console.WriteLine();
int roll = Random.Shared.Next(1, 7);Console.WriteLine($"Solar flare check, rolled: {roll}");
if (roll >= 5){ Console.WriteLine("Flare detected.");}else{ Console.WriteLine("Skies clear.");}
Console.WriteLine();
// Roll a second die, 1 to 6, into its own variable// Show the second die// If the two dice match, it is a critical event// inside that, if the matched value is 6, say "CRITICAL: total systems failure"// otherwise say "CRITICAL: minor fault" and show the value// If they do not match, say "No event."Two changes, one at a time. Write down exactly what happens, and put each back before the next.
Random.Shared.Next(1, 6). Run the program twenty times and tally every value you get.Random.Shared.Next(7, 1) — the same two numbers, the wrong way round — and run it once.For number 1, record your twenty values and the highest one you saw. For number 2, record the error and the line it names.
One of these stopped the program immediately. The other ran perfectly twenty times in a row and is still wrong. Say which is which, and how many more runs you would want before you would be willing to call the first one broken.
int roll = 6; so you can choose the value yourself.Your finished program should run like this — though yours will not match, and should not. The two dice are different every run, and this particular one is a double six.
DENIED: crew too small
Solar flare check, rolled: 6Flare detected.
Second die: 6CRITICAL: total systems failureAnswer the following questions before submitting your work.
Random.Shared.Next(1, 6) never produces a 6, and nothing warns you. Explain why running the program a few times is not enough to catch that, and what you would do instead.&& or with a nest. Describe what each one is better at, and what the program has to do for the difference to matter.Submit four things to the dropbox: