'F' → Fullscreen
Everything today goes in a new program named 1-15-systems.
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.
anyLow true and allFine false. Make sure you can say why for both.int oxygen = 88;int coolant = 18;int power = 132;
bool anyLow = oxygen < 25 || coolant < 25 || power < 25;bool allFine = oxygen >= 25 && coolant >= 25 && power >= 25;
Console.WriteLine($"Any system low: {anyLow}");Console.WriteLine($"All systems fine: {allFine}");Console.WriteLine($"Not all fine: {!allFine}");int oxygen = 88;int coolant = 18;int power = 132;
bool anyLow = oxygen < 25 || coolant < 25 || power < 25;bool allFine = oxygen >= 25 && coolant >= 25 && power >= 25;
Console.WriteLine($"Any system low: {anyLow}");Console.WriteLine($"All systems fine: {allFine}");Console.WriteLine($"Not all fine: {!allFine}");Console.WriteLine();
if (anyLow){ Console.WriteLine("STATUS: attention required");}else{ Console.WriteLine("STATUS: nominal");}
if (oxygen >= 25 && power >= 130){ Console.WriteLine("Cleared for long haul.");}else{ Console.WriteLine("Short trips only.");}crewSize >= 2 was for.int oxygen = 88;int coolant = 18;int power = 132;
bool anyLow = oxygen < 25 || coolant < 25 || power < 25;bool allFine = oxygen >= 25 && coolant >= 25 && power >= 25;
Console.WriteLine($"Any system low: {anyLow}");Console.WriteLine($"All systems fine: {allFine}");Console.WriteLine($"Not all fine: {!allFine}");Console.WriteLine();
if (anyLow){ Console.WriteLine("STATUS: attention required");}else{ Console.WriteLine("STATUS: nominal");}
if (oxygen >= 25 && power >= 130){ Console.WriteLine("Cleared for long haul.");}else{ Console.WriteLine("Short trips only.");}
Console.WriteLine();
// Ask for a crew size and convert it// Ask for a cargo mass and convert it// Store whether the crew is at least 2, and whether the mass is under 500// A launch is allowed only if both are true -- approve it, or deny itTwo changes, one at a time. Write down exactly what happens, and put each back before the next.
massOk with cargoMass < 500 || 2. Try to run it.anyLow to read oxygen < 25 || coolant < 25 && power < 25 — no parentheses — and run it with oxygen 18, coolant 88, power 132.For each one, record the error code if there was one, and the line it names.
One of these will not build. The other builds, runs, and gives a different answer than the version with parentheses. Say which is which, and what the second one printed instead.
allFine and anyLow look like opposites. Add a line that stores !anyLow and print it next to allFine.!anyLow and allFine mean the same thing, and how you convinced yourself.bool canLaunch = fuelOk && crewOk;bool anyFault = fuelLow || powerLow;bool allClear = !anyFault;canLaunch ← fuelOk AND crewOkanyFault ← fuelLow OR powerLowallClear ← NOT anyFaultThis is one of the easy panels. The exam writes the operators as words, and the words are exactly what the symbols mean.
| Meaning | C# | Exam notation |
|---|---|---|
| Both must be true | && | AND |
| At least one must be true | || | OR |
| Flip it | ! | NOT |
Reading them aloud is a genuine exam technique. NOT anyFault says what it does. !anyFault says the same thing, and the exclamation mark is easy to miss in a long line — which is exactly how it gets misread under time pressure.
The precedence rule is the same in both. The reference sheet applies NOT first, then AND, then OR — which is C#'s order exactly. An exam question that omits the parentheses is testing whether you know that.
Your finished program should run like this.
Any system low: TrueAll systems fine: FalseNot all fine: True
STATUS: attention requiredCleared for long haul.
Crew size? 1 [Enter]Cargo mass? 300 [Enter]LAUNCH DENIEDTrue or False, with a capital letterAnswer the following questions before submitting your work.
day == 6 || 7 reads like correct English but will not compile. Explain what || actually needs on each side.anyLow as one combined condition, or as three separate if statements. What does storing it in a named boolean give you that neither of those does?Submit four things to the dropbox: