Develop the logical solution
Understand the problem
Plan/design the logic
Translate into code
2. (TCO 2) Which variable name is invalid?
All of the above are valid.
3. (TCO 3) What symbol in a flowchart would be used by a developer to represent a calculation (process)?
4. (TCO 2) You are using dollar amounts in an algorithm. What data type would you assign to the cost variable?
Any of the above
5. (TCO 3) _____ can be used to describe the steps of a solution algorithm.
Either A or B
6. (TCO 2) When an expression includes relational, logical, and arithmetic operators, which type of operator is evaluated first?
It depends on the expression.
7. (TCOs 2, 7) What is the problem with the following assignment statement, given that grade is an integer variable?
150 = grade
The answer 150 is not a reasonable grade.
The data types don’t match.
The answer 150 should be in quotes.
The variable must be on the left side.
8. (TCO 2) What value will be contained in the variable x after the following statement is executed?
x = 10 + 8 / 2 * 3
9. (TCO 2) If you use a loop to sum up a number of test scores, you will need a variable to act as a(n) ____.
10. (TCO 4) For the following expression to be true, _____.
condition1 AND condition2
both conditions must be false
both conditions must be true
either condition can be false
either condition can be true
11. (TCOs 2, 7, 8) Review the partial pseudocode below. What is the correct math expression to complete the algorithm and calculate 25% of a cost?
Prompt “Enter total cost: “
Display “25% of the cost is: “ + total
total = cost
total = cost * 0.25
total = cost / 0.25
total = cost * 25%
12. (TCOs 3, 4, 8) Review the pseudocode below. What will be displayed when this algorithm executes?
Set x = 5
If ((x >= 10) AND (x < 20)) then
Display “the IF path executes”
Display “the ELSE path executes”
the ELSE path executes
the IF path executes
(x >= 10) AND (x< 20)
13. (TCOs 3, 4, 8) What value gets displayed for the variable X?
Set A = 5
Set B = 20
Set C = 15
If (B > 15) AND (A = 5) AND (C <= 15) then
Set X = 1
Set X = 0
14. (TCOs 3, 4, 8) In the following pseudocode, what raise will an employee in Department 6 receive?
If department < 2 then
Set raise = 1000
If department < 6 then
Set raise = 2500
Set raise = 3000
15. (TCOs 3, 4) Which of the selection structures determines whether the user enters a number outside a range of 20 and 45?
If commission <> 45
If commission <= 45
If (commission >= 20) AND (commission <=45)
If (commission < 20) OR (commission > 45)
16. (TCOs 3, 4, 8) What value gets displayed for the variable Z?
Set balance = 800
Set stateCode = 8
Set creditCode = 9
If (balance <> 800) AND (stateCode<> 6) AND (creditCode<> 7) then
Set Z = 3
Set Z = 2
17. (TCO 5) Repetition that loops a certain number of times is typically referred to as _____.
a count-controlled loop
an event-controlled loop
an endless loop
an infinite loop
18. (TCO 5) Which loop must execute the body of the loop at least once?
A pretest loop
A post-test loop
A sequence structure
A selection structure
19. (TCO 5) In the following code, how many times will the loop body be executed?
Dim num As Integer
For num = 10 to 20 Step 5
20. (TCOs 3, 5, 8) In the following code, how many times will the loop body be executed?
Dim x as Integer
x = 1
While x <> 6
x = x + 1
21. (TCO 6) What is an array element?
A specific value in an array
An alternate name for an array
A number that indicates the position of a particular item within an array
A number that represents the highest value stored within an array
22. (TCO 6) What is the value of the index used to access the first element in a Visual Basic array declared as the following?
Dim num(20) As Integer
23. (TCOs 5, 6) What statement will be placed in the loop body to double each value of the array specified in the code below?
Dim nums(5) As Integer
Dim index As Integer
For index = 0 to 5
What statement goes here?
nums = nums * 2
nums(index) * 2
nums(index) = nums(index) * 2
None of the above
24. (TCO 6) A zero-based array named quantity has been declared and loaded with the values 100, 250, 150, 210, and 550. What value(s) will be stored in the array element quantity(1)?
250, 150, 210, 550
25. (TCOs 7, 8) What type of error occurs when an array subscript’s value goes beyond the total number of elements in the array?
26. (TCOs 3, 8) Which type of statement is necessary at the end of a function?
PART 2(5 points): Create a function called calcDiscount that will calculate and return the discount amount. Write the function and call it in the code. (Points : 15)
28 (TCOs 5, 8) Write a Visual Basic loop that displays the even numbers from 20 to 60. (Points : 10)