COSC 2409Fall 2000

Exam 1 - Answers

For each of the following questions choose (a) for true and (b) for false, and code your choice in the answer sheet.

1.True - Although a flowchart (as its name suggests) depicts data flow very well, it is not easily modified once written.

2.False - The following two statements are equivalent.

num1 = num2

num2 = num1

3.False - The following If block is valid.

If a < b Or > c Then

picBox.Print a

End If

4.True - The End If statement may be omitted if the If statement is written on a single line.

5.True - One may use a Select Case block within an If block.

6.False - Changing a control's Caption property also changes how you refer to the control in code.

7.False - Given that x = 7, y = 2, and z = 4, the following If block will display "TRUE".

If (x > y) And (y > z) Then

picBox.Print "TRUE"

End If

8.False - A hierarchy chart is the same thing as a flowchart.

9.False - The following statements assign the lowercase letters to the string variable alphabet.

Dim alphabet As String

alphabet = abcdefghijklmnopqrstuvwxyz

For each of the following questions choose the best possible answer from choices (a) through (d), and code your choice in the answer sheet.

10.Which of the following is the proper order of procedures used in the problem-solving process?

(A)Design, analysis, coding, testing

(B)Analysis, testing, design, coding

*(C)Analysis, design, coding, testing

(D)Analysis, design, testing, coding

11.The process of finding and correcting errors in a program is called

(A)pseudocoding.

*(B)debugging.

(C)algorithms.

(D)development cycles.

12.Which of the following is a valid statement in Visual Basic?

*(A)txtBox.Text = "Hello"

(B)lblName.Text = "Bob"

(C)cmdButton.Caption = Push Me

(D)picBox.Print = "Hello"

13.A user action such as clicking a command button is called:

(A)An accident

*(B)An event

(C)A procedure

(D)A property

14.The Cls method removes text and graphics from a

*(A)picture box.

(B)text box.

(C)label.

(D)command button.

15.Assume that x, y, and temp are numeric variables. Which of the following lines of code swaps the values of x and y?

(A)x = y

y = x

(B)x = temp

x = y

y = temp

*(C)temp = x

x = y

y = temp

(D)x = y

temp = x

y = temp

16.The symbol for the string concatenation operator is

(A)@

*(B)

(C)%

(D)#

17.Visual Basic can require all variables to be declared by which of the following statements?

(A)Option Declare

*(B)Option Explicit

(C)Dim All

(D)None of the above

18.Suppose a file has been opened with reference number 2. Which of the following statements assigns a value from the file to the variable person?

(A)person = Input #2

*(B)Input #2, person

(C)person = InputBox(2)

(D)Input #2 = person

19.Given the data in the string variable y shown below, which of the following statements will assign the value ALL to the string variable x?

y = "WHEN ALL ELSE FAILS, READ THE DIRECTIONS"

*(A)x = Mid(y, 6, 3)

(B)x = Mid(6, y, "ALL")

(C)x = Left(y, 3)

(D)x = Middle(y, 6, 3)

20.What will be the output of the following program when the command button is clicked?

Private Sub cmdButton_Click()

Dim x As Single, y As Single, z As Single

x = 3

y = 3

If x > y Then

z = x + y

Else

z = y - x

End If

picBox.Print z

End Sub

(A)6

(B)3

*(C)0

(D)No output

21.What will be the output of the following program when the command button is clicked?

Private Sub cmdButton_Click()

Dim nom As String

nom = "Washington"

Select Case nom

Case "George"

picBox.Print "George";

Case "Wash"

picBox.Print "Wash";

Case "WASHINGTON"

picBox.Print "WASHINGTON";

Case Else

picBox.Print "Washington";

End Select

End Sub

(A)WashWashington

*(B)Washington

(C)WASHINGTONWashington

(D)No output

22.In analyzing the solution to a program, you conclude that you want to construct a loop so control leaves the loop either when a < 12 or when b = 16. Using a Do loop, the test condition should be

(A)Do While (a > 12) Or (b >16)

*(B)Do While (a >= 12) Or (b > 16)

(C)Do While (a < 12) Or (b > 16)

(D)Do While (a < 12) And (b = 16)

23.When the number of repetitions needed for a set of instructions is known before they are executed in a program, the best repetition structure to use is a(n)

(A)Do While...Loop structure.

(B)Do...Loop Until structure.

*(C)For...Next loop.

(D)If block with a GoTo statement.

24.Which statement prompts the user for a name and then assigns the name to the string variable strName?

*(A) strName = InputBox("What is your first name?", "First Name")

(B)strName = Msgbox "What is your first name?", "First Name"

(C)InputBox("What is your first name?", "First Name")= strName

(D)Msgbox "What is your first name?", "First Name" = strName

25.Pseudocode is

(A)data that have been encoded for security.

(B)the incorrect results of a computer program.

*(C)a description of an algorithm similar to a computer language.

(D)the obscure language computer personnel use when speaking.

26.Federal law requires hourly employees be paid “time-and-a-half” for work in excess of 40 hours per week. For example, if a person’s hourly wage is $8 and he works 60 hours in a week, his gross pay should be

(40 * 8) + (1.5 * 8 * (60 – 40)) = $560

Write a program that requests as input the number of hours a person works in a given week and his hourly wage, and then displays his gross pay. Include a form caption of Pay Computation and format the pay to currency.

Turn in a printout of your code, and your program on a diskette.