Which general type of statement would you use to implement each of the following logical descriptions:
Suppose that your program contains three variables called rainfall, wind, and temperature, all of type double. For each of the following points, write a few lines of code that implement the described logic (you don't need to write the whole program):
No matter which value rainfall has, the following lines will always write "It's raining" onscreen. Why?
if(rainfall > 10); Console.WriteLine("It's raining");
What is the purpose of nested if statements?
Write logical expressions (using C#'s comparison operators and logical operators) that represent the following conditions:
A method with the header bool IsEven(int number) returns true if the argument passed to its parameter number is even; otherwise, it returns false. Write a Boolean expression containing a call to IsEven that is true if the number passed along with the call is odd.
To what does the term scope refer?
What is one of the few correct uses of the goto statement?
Rewrite the following if-else multibranch statement using a switch statement.
if(timeOfDay == "morning") Console.WriteLine("Good Morning"); else if(timeOfDay == "midday") Console.WriteLine("Good Day"); else if(timeOfDay == "evening") Console.WriteLine("Good evening"); else Console.WriteLine("Invalid time");
To what does "falling through" in relation to the switch statement refer? How can "falling through" be prevented?
Your program contains variables called cost1, cost2, and minimumCost. Write a statement involving the conditional operator that assigns the smaller of the values in cost1 and cost2 to minimumCost.