c# chapter 5 part 1
A company issues $5,000.00 bonuses at the end of the year to all employees who earn less than $100,000. Salary and bonus are both defined as double data types. Which of the following selection statements would assign the correct amount to bonus?
if (salary < 100000)
bonus = 5000;
f (a > 10)
if (b > 10)
if (c > 10)
result = 1;
else
if (b > 100)
result = 2;
else
result = 3;
else
result = 4;
else
result = 5;
Using the above code segment, what is stored in result when a, b and c are equal to 200?
1
if (amount > 1000)
result = 1;
else
if (amount > 500)
result = 2;
else
if (amount > 100)
result = 3;
else
result = 4;
Using the above code segment, what is stored in result when amount is equal to 876?
2
if (aValue < largest )
result = aValue;
else
result = largest;
What happens when aValue is equal to largest in the program segment above?
result is assigned largest
if (examScore > 89)
grade = 'A';
Console.WriteLine("Excellent");
Using the code snippet above, when does Excellent get displayed?
every time the program is run
if (examScore > 89);
grade = 'A';
Using the code snippet above, when does grade get assigned a value of 'A'?
every time the program is run
if (examScore is less than 50)
display message "Do better on next exam"
The result of the expression above is ____?
the answer cause boolean:true or false
switch (phoneDigit)
{
case 1: num = 1;
break;
case 2: num = 2;
break;
case 3: num = 3;
break;
case 4: num = 4;
break;
default: num = 0;
break;
}
Looking at the example above, what happens if the break is omitted?
a syntax error is generated
he expression, (5 > 57 % 8), evaluates to ___?
True
The switch statement case value can evaluate to all of the following EXCEPT ____?
double
When you compare characters stored in char memory locations using relational operators, ____?
they are compared lexicographically
Which of the following statements is NOT true regarding switch statements?
Default is required.
By properly_____ the else clauses with their corresponding if clauses, you encounter fewer logic errors that necessitate debugging?
lining up
Conditional expressions produce a / an ____result?
boolean
____operators allow you to test variables to see if one is greater or less than
another variable or value?
Relational
After completing the program, you should compare the results produced with the desk checked calculated results?
True or False?
True
Boolean variables store 0 to represent off or false and 1 to represent on or true?
True or False?
False
Class diagrams list the data field members in the center rectangle and the methods or behaviors in the bottom rectangle?
True or False?
True
Equality comparisons with floating-point and decimal types often produce unpredictable results?
True or False?
True
In C#, both the break and default are optional entries found with a switch statement?
True or False?
False
In C#, the && and || operators are also called the short-circuiting logical operators?
True of False?
True
Iteration, also called selection is used for decision making and allows your program statements to deviate from the sequential path and perform different statements based on the value of an expression?
True or False?
False
Iteration, also called selection is used for decision making and allows your program statements to deviate from the sequential path and perform different statements based on the value of an expression?
True or False?
True
The ternary operator ( ? : ) provides another way to express a simple if...else selection statement?
True or False?
True
The ternary operator ( ? : ) provides another way to express a simple if...else selection statement?
True or False?
False