# Expert Answer of the following Questions

Multiple Choice

1. (TCO 1) What is the first step in software development?
Develop the logical solution
Understand the problem
Plan/design the logic
Translate into code

2. (TCO 2) Which variable name is invalid?
tax_rate
StudentName
2012budget
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)?
Rectangle
Diamond
Parallelogram
Lozenge

4. (TCO 2) You are using dollar amounts in an algorithm. What data type would you assign to the cost variable?
Integer
Real
String
Any of the above

5. (TCO 3) _____ can be used to describe the steps of a solution algorithm.
Pseudocode
Flowcharts
Desk-checking
Either A or B

6. (TCO 2) When an expression includes relational, logical, and arithmetic operators, which type of operator is evaluated first?
Arithmetic
Relational
Logical
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?
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
3
45
22
27

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) ____.
flag
symbol
counter
accumulator

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: “
Input cost
Set _____
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”
Else
Display “the ELSE path executes”
EndIf
10
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
Else
Set X = 0
EndIf
Display X
1
5
0
10

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
Else
If department < 6 then
Set raise = 2500
Else
Set raise = 3000
EndIf
EndIf
1,000
2,500
3,000
0

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
Else
Set Z = 2
EndIf
Display Z
6
2
3
7

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
Console.writeline(num)
Next
Zero times
Three times
Four times
Six times

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
Console.Writeline(x)
x = x + 1
End While
Zero times
One time
Five times
Six times

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
20
9
1
0

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?
Next
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)?
100
250
150
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?
Syntax error
Runtime error
Logic error
Out-of-bounds error

26. (TCOs 3, 8) Which type of statement is necessary at the end of a function?
Input
Assignment
Call
Return

Long Questions

27. PART 1 (10 points): A furniture store is having a customer appreciation sale. Depending on the total dollars purchased, the customer could receive a discount on his or her total purchases. You are to develop pseudocode that will obtain the total dollars purchased from the user, determine the discount percentage, and display the total amount due. When the purchases are more than \$2,000, the discount is 12%. When the purchases are \$2,000 or less, the discount is 7%.
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)