Introduction to Programming Using Visual Basic 2012 9th Edition Schneider Test Bank instant download
Introduction to Programming Using Visual Basic 2012 9th Edition Schneider Test Bank instant download
https://testbankdeal.com/product/introduction-to-programming-
using-visual-basic-2012-9th-edition-schneider-test-bank/
https://testbankdeal.com/product/introduction-to-programming-using-
visual-basic-2012-9th-edition-schneider-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/introduction-to-programming-using-
visual-basic-10th-edition-schneider-test-bank/
testbankdeal.com
https://testbankdeal.com/product/introduction-to-programming-using-
visual-basic-10th-edition-schneider-solutions-manual/
testbankdeal.com
https://testbankdeal.com/product/human-genetics-concepts-and-
applications-11th-edition-ricki-lewis-solutions-manual/
testbankdeal.com
Management of Human Resources The Essentials Canadian 4th
Edition Dessler Test Bank
https://testbankdeal.com/product/management-of-human-resources-the-
essentials-canadian-4th-edition-dessler-test-bank/
testbankdeal.com
https://testbankdeal.com/product/police-field-operations-theory-meets-
practice-2nd-edition-birzer-test-bank/
testbankdeal.com
https://testbankdeal.com/product/foundations-of-microeconomics-7th-
edition-bade-test-bank/
testbankdeal.com
https://testbankdeal.com/product/american-political-system-with-
policy-chapters-2014-election-update-2nd-edition-kollman-test-bank/
testbankdeal.com
https://testbankdeal.com/product/quantitative-human-physiology-an-
introduction-1st-edition-feher-solutions-manual/
testbankdeal.com
McGraw Hills Essentials of Federal Taxation 2019 10th
Edition Spilker Solutions Manual
https://testbankdeal.com/product/mcgraw-hills-essentials-of-federal-
taxation-2019-10th-edition-spilker-solutions-manual/
testbankdeal.com
Chapter 6 Repetition
2. What numbers will be displayed in the list box when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num as Double = 10
Do While num > 1
lstBox.Items.Add(num)
num = num - 3
Loop
End Sub
5. In analyzing the solution to a program, you conclude that you want to construct a loop so
that the loop terminates 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)
(E) Do While (a < 12) And (b = 16)
D
6. When Visual Basic executes a Do While loop it first checks the truth value of the
_________.
(A) pass
(B) loop
(C) condition
(D) statement
C
7. If the loop is to be executed at least once, the condition should be checked at the
__________.
(A) top of the loop
(B) middle of the loop
(C) bottom of the loop
(D) Nothing should be checked.
C
8. A Do While loop checks the While condition before executing the statements in the loop.
(T/F)
T
9. If the While condition in a Do While loop is false the first time it is encountered, the
statements in the loop are still executed once. (T/F)
F
10. The following statement is valid. (T/F)
Do While x <> 0
T
11. The following two sets of code produce the same output. (T/F)
Dim num As Integer = 1 Dim num As Integer = 1
Do While num <=5 Do
lstBox.Items.Add("Hello") lstBox.Items.Add("Hello")
num += 1 num += 1
Loop Loop Until (num > 5)
T
12. A loop written using the structure Do While...Loop can usually be rewritten using the
structure Do...Loop Until. (T/F)
T
13. A variable declared inside a Do loop cannot be referred to outside of the loop. (T/F)
T
14. Assume that i and last are Integer variables. Describe precisely the output produced by the
following segment for the inputs 4 and –2.
Dim last, i As Integer
last = CInt(InputBox("Enter terminating value:"))
i = 0
Do While (i <= last)
lstBox.Items.Add(i)
i += 1
Loop
(Input 4): 0 1 2 3 4
(Input –2): No output
15. The following is an infinite loop. Rearrange the statements so that the loop will terminate as
intended.
x = 0
Do
lstBox.Items.Add(x)
Loop Until x > 13
x += 2
Move the last statement one line up, before the Loop Until statement
16. What is wrong with the following simple password program where today's password is
"intrepid"?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim password As String
password = InputBox("Enter today's password:")
Do
lstBox.Items.Add("Incorrect")
password = InputBox("Enter today's password:")
Loop Until password = "intrepid"
lstBox.Items.Add("Password Correct. You may continue.")
End Sub
(A) There is no way to re-enter a failed password.
(B) The Loop Until condition should be passWord <> "intrepid".
(C) It will display "Incorrect." even if the first response is "intrepid".
(D) Nothing
C
17. How many times will HI be displayed when the following lines are executed?
Dim c As Integer = 12
Do
lstBox.Items.Add("HI")
c += 3
Loop Until (c >= 30)
(A) 5
(B) 9
(C) 6
(D) 4
(E) 10
C
22. The following are equivalent While and Until statements. (T/F)
While (num > 2) And (num < 5)
Until (num <= 2) Or (num >= 5)
T
1. 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 blocks.
C
3. When the odd numbers are added successively, any finite sum will be a perfect square (e.g.,
1 + 3 + 5 = 9 and 9 = 3^2). What change must be made in the following program to correctly
demonstrate this fact for the first few odd numbers?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim oddNumber As Integer
Dim sum As Integer = 0
For i As Integer = 1 To 9 Step 2 'Generate first few odd numbers
oddNumber = i
For j As Integer = 1 To oddNumber Step 2 'Add odd numbers
sum += j
Next
lstBox.Items.Add(sum & " is a perfect square.")
Next
End Sub
(A) Change the Step size to 1 in the first For statement.
(B) Move oddNumber = i inside the second For loop.
(C) Reset sum to zero immediately before the second Next statement.
(D) Reset sum to zero immediately before the first Next statement.
C
4. What does the following program do with a person's name?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim name, test As String
Dim n As String = ""
name = InputBox("Enter your first name:")
For i As Integer = 0 To (name.Length - 1) Step 2
test = name.Substring(i, 1)
n = test & n
Next
txtBox.Text = n
End Sub
It displays the name
(A) in reverse order.
(B) in reverse order and skips every other letter.
(C) as it was entered.
(D) as it was entered, but skips every other letter.
B
5. Suppose the days of the year are numbered from 1 to 365 and January 1 falls on a Tuesday
as it did in 2013. What is the correct For statement to use if you want only the numbers for
the Fridays in 2013?
(A) For i As Integer = 3 to 365 Step 7
(B) For i As Integer = 1 to 365 Step 3
(C) For i As Integer = 365 To 1 Step -7
(D) For i As Integer = 3 To 365 Step 6
A
6. Given the following partial program, how many times will the statement
lstBox.Items.Add(j + k + m) be executed?
For j As Integer = 1 To 4
For k As Integer = 1 To 3
For m As Integer = 2 To 10 Step 3
lstBox.Items.Add(j + k + m)
Next
Next
Next
(A) 24
(B) 60
(C) 36
(D) 10
(E) None of the above
C
7. Which of the following program segments will sum the eight numbers input by the user?
(A)For k As Integer = 1 To 8
s = CDbl(InputBox("Enter a number.")
s += k
Next
(B) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
s += 1
Next
(C) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
a += s
Next
(D) For k As Integer = 1 To 8
a = CDbl(InputBox("Enter a number.")
s += a
Next
D
8. What will be displayed by the following program when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim a As String, n, c As Integer
a = "HIGHBACK"
n = CInt(Int(a.Length / 2))
c = 0
For k As Integer = 0 To n – 1
If a.Substring(k, 1) > a.Substring(7 – k, 1) Then
c += 1
End If
Next
txtBox.Text = CStr(c)
End Sub
(A) 1
(B) 2
(C) 3
(D) 4
(E) 5
C
9. In a For statement of the form shown below, what is the default step value when the "Step c"
clause is omitted?
For i As Integer = a To b Step c
(A) the same as a
(B) the same as b
(C) 0
(D) 1
D
10. What will be displayed when the following lines are executed?
txtBox.Clear()
For k As Integer = 1 To 3
txtBox.Text &= "ABCD".Substring(4 – k, 1)
Next
(A) ABC
(B) CBA
(C) DBA
(D) DCBA
(E) DCB
E
11. Which loop computes the sum of 1/2 + 2/3 + 3/4 + 4/5 + … + 99/100?
(A) For n As Integer = 1 To 99
s += n / (1 + n)
Next
(B) For q As Integer = 100 To 1
s += (q + 1) /q
Next
(C) For d As Integer = 2 To 99
s = 1 / d + d / (d + 1)
Next
(D) For x As Integer = 1 To 100
s += 1 / (x + 1)
Next
A
12. How many times will PETE be displayed when the following lines are executed?
For c As Integer = 15 to -4 Step -6
lstBox.Items.Add("PETE")
Next
(A) 1
(B) 2
(C) 3
(D) 4
D
13. What will be displayed by the following program when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim s As Double
s = 0
For k As Integer = 1 To 5
If k / 2 = Int(k / 2) Then
s += k
End If
Next
txtBox.Text = CStr(s)
End Sub
(A) 12
(B) 9
(C) 15
(D) 6
D
14. How many lines of output are produced by the following program segment?
For i As Integer = 1 To 3
For j As Integer = 1 To 3
For k As Integer = i to j
lstBox.Items.Add("Programming is fun.")
Next
Next
Next
(A) 8
(B) 9
(C) 10
(D) 11
C
15. Assuming the following statement, what is the For...Next loop's counter variable?
For yr As Integer = 1 To 5
(A) 1
(B) 5
(C) To
(D) yr
D
16. What is the value of j after the end of the following code segment?
For j As Integer = 1 to 23
lstBox.Items.Add("The counter value is " & j)
Next
(A) 22
(B) 23
(C) 24
(D) j no longer exists
D
17. A For...Next loop with a positive step value continues to execute until what condition is
met?
(A) The counter variable is greater than the terminating value.
(B) The counter variable is equal to or greater than the terminating value.
(C) The counter variable is less than the terminating value.
(D) The counter variable is less than or equal to the terminating value.
A
18. Which of the following loops will always be executed at least once when it is encountered?
(A) a For...Next loop
(B) a Do loop having posttest form
(C) a Do loop having pretest form
(D) none of the above.
B
19. Which of the following are valid for an initial or terminating value of a Fir...Next loop?
(A) a numeric literal
(B) info.Length, where info is a string variable
(C) a numeric expression
(D) All of the above
D
20. What is the data type of the variable num if Option Infer is set to On and the statement
Dim num = 7.0 is executed?
(A) Integer
(B) Boolean
(C) Double
(D) String
C
21. The value of the counter variable should not be altered within the body of a For…Next loop.
(T/F)
T
22. The body of a For...Next loop in Visual Basic will always be executed once no matter what
the initial and terminating values are. (T/F)
F
23. If the terminating value of a For...Next loop is less than the initial value, then the body of the
loop is never executed. (T/F)
F
24. If one For...Next loop begins inside another For...Next loop, it must also end within this
loop. (T/F)
T
25. The value of the counter variable in a For...Next loop need not be a whole number. (T/F)
T
26. One must always have a Next statement paired with a For statement. (T/F)
T
27. If the initial value is greater than the terminating value in a For...Next loop, the statements
within are still executed one time. (T/F)
F
28. When one For...Next loop is contained within another, the name of the counter variable for
each For...Next loop may be the same. (T/F)
F
31. In a For...Next loop, the initial value should be greater than the terminating value if a
negative step is used and the body of the loop is to be executed at least once. (T/F)
T
32. If the counter variable of a For...Next loop will assume values that are not whole numbers,
then the variable should not be of type Integer. (T/F)
T
33. The step value of a For...Next loop can be given by a numeric literal, variable, or expression.
(T/F)
T
34. The variable index declared with the statement For index As Integer = 0 To 5 cannot
be referred to outside of the For…Next loop. (T/F)
T
35. When Option Infer is set to On, a statement of the form Dim num = 7 is valid. (T/F)
T
36. What is displayed in the text box when the button is clicked?
Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim word As String = "Alphabet"
Dim abbreviation As String = ""
For i As Integer = 0 To word.Length - 1
If word.Substring(i, 1).ToUpper <> "A" Then
abbreviation &= word.Substring(i, 1)
End If
Next
txtBox.Text = abbreviation
End Sub
lphbet
1. Which of the following expressions refers to the contents of the last row of the list box?
(A) lstBox.Items(lstBox.Items.Count)
(B) lstBox.Items(lstBox.Items.Count - 1)
(C) lstBox.Items(Count)
(D) lstBox.Items.Count
B
2. Which of the following expressions refers to the contents of the first row of the list box?
(A) lstBox.Items(0)
(B) lstBox.Items(1)
(C) lstBox.Items.First
(D) lstBox.Items(First)
A
3. Each item in a list box is identified by an index number; the first item in the list is assigned
which of the following values as an index?
(A) a randomly assigned value
(B) 1.
(C) a value initially designated by the programmer
(D) 0
D
4. The following lines of code display all the items of lstBox. (T/F)
For n As Integer = 1 to lstBox.Items.Count
lstBox2.Items.Add(lstBox.Items(n))
Next
F
8. A list box named lstBox has its Sorted property set to True and contains the three items Cat,
Dog, and Gnu in its Items collection. If the word Elephant is added to the Items collection at
run time, what will be its index value?
(A) 2
(B) 1
(C) 3
(D) 0
A
9. A list box named lstBox has its Sorted property set to False and contains the three items Cat,
Dog, and Gnu in its list. If the word Elephant is added to the list at run time, what will be its
index value?
(A) 2
(B) 1
(C) 3
(D) 0
C
10. If a program contains procedures for both the Click and DoubleClick events on a list box and the user
double-clicks on the list box, only the Click event will be raised. (T/F)
T
11. If a list box has its sorted property set to True and the list box contains all numbers, then the values in
the list box will always be in increasing numerical order. (T/F)
F
12. If a list box contains all numbers, then which of the following values can be calculated
without using a loop?
(A) average value of the numbers
(B) largest number
(C) smallest number
(D) number of numbers
D
13. Which of the following is not a main type of event that can be raised by user selections of
items in a list box?
(A) Click event
(B) SelectedIndexChanged event
(C) FillDown event
(D) DoubleClick event
C
14. The value of lstBox.Items(n) is the nth item in the list box. (T/F)
F
15. The sorted property can only be set to True at design time. (T/F)
F
17. A variable that keeps track of whether a certain situation has occurred is called
(A) a counter.
(B) an accumulator.
(C) a switch.
(D) a flag.
D
Another Random Scribd Document
with Unrelated Content
the ardent and influential support of the owners of suburban land,
who would rejoice in the increase of their rents, brought about by
the expenditure of public money in creating railway facilities on
uncommercial terms. These are not fanciful dangers. They are the
results which we may feel sure would inevitably follow the
nationalization of our railways, and the advantages to be gained
from State management would need to be very great to compensate
for these burdens.
Another aspect of the question which requires the gravest
consideration is that which concerns the position of the State as an
employer of labor. There are upwards of 620,000 railway officers and
servants. The State would become the direct employer of that huge
army, and would have to settle all questions relating to hours,
wages, and other conditions of service. If a railway company is
unable to settle differences with its men the ultimate resort of the
men is the withdrawal of their labor, whilst the company are free to
employ other men who are willing to accept their conditions of
employment. Any railway strike on a large scale is a dire calamity to
trade and to the public, but if one were compelled to consider the
possibility of a general strike on a national railway system, even the
deplorable results which accompany strikes on privately-owned
railways would seem comparatively insignificant. Probably a railway
department of Government would not urge the adoption of
compulsory arbitration, if they were themselves concerned, with as
much equanimity as they do in the case of strikes on private
railways. It is true that in this matter the advocates of State railways
can point to the comparative absence of labor conflicts in connection
with the services now under Government control, but municipal
undertakings have not been so successful in avoiding labor disputes,
and in many cases have secured even the degree of immunity from
such conflicts which they enjoy by the concession of terms of
employment which constitute heavy burdens on the ratepayers. It
seems to me that the danger of serious labor disputes cannot be put
aside, and I confess that I am unable to see any safe way of
meeting the objection to State ownership on the ground that the
State ought to limit, as far as possible, its liability to become directly
concerned in such disputes.
In conclusion, I would say that I have felt unable to take up a
partisan attitude on the question. For many years past both my
studies on railway subjects and my practical experience have led me
to a convinced belief in the advantages of well-regulated monopoly,
and I am unable wholly to disapprove of a scheme which would
secure for the country the advantages of a system of well-regulated
monopoly in which I believe, even although it should come in the
guise of State ownership.
Competition, in my judgment, creates more evils than it cures,
especially the half-hearted and imperfect competition which exists in
England so far as railways are concerned, which cannot be regarded
as free competition on a commercial basis.
I recognize that it is impracticable to secure unification or any very
extensive or far-reaching combinations of railways under our system
of private ownership. The public would not tolerate uncontrolled
railways under private management, and I doubt whether any form
of control which has yet been devised, or is likely to be devised,
combined with partial competition, can give entirely satisfactory
results. That there are grave dangers and risks in the public
ownership of railways I fully admit; indeed, so grave are they, that I
think he would be a very bold minister who would venture to bring
forward, under Government sanction, a proposal for the
nationalization of our railways. The existence of such a huge amount
of Government patronage would open the door to political
corruption. The existence of such an enormous body of Government
servants possessing the franchise—and I confess it seems to me
impracticable to hope that any measure could be carried subject to
disfranchisement of Government servants—would imperil the
financial stability of the railway system, and introduce new and very
serious sources of weakness and danger into the body politic.
The risk of loss from the charging of unduly low rates under
pressure from the influential body of traders seeking to enrich
themselves at the expense of the general community seems to me a
risk which no thoughtful man can ignore. No expedients for checking
and restraining political influence so that it could not reach or sway
the decision of the officers of State responsible for railway
management seem to me practicable under our democratic
constitution.
If the nation owns the railways, the nation must take all the risks
of State ownership, and we could only trust that the existing purity
of our politics and the common sense, honorable character, and long
experience in self-government of the English people would suffice to
protect the commonwealth from these perils resulting in serious
harm. But whatever may be the issue of the consideration of the
question of State purchase of railways, I am prepared to believe that
English railways will continue, whether under State management or
under private management, to deserve the praise which Mr. W. M.
Acworth expressed in his recent address as President of the
Economic Section of the British Association in Dublin, by saying that
in his judgment—after, I may remind you, a fuller study of railway
conditions in all countries of the world than has been given to the
subject of many men in England—that "English railways are, on the
whole, among the best, if not actually the best, in the world."
CONCERNING ADVANCES IN RAILWAY
RATES
February 8, 1909.—Ordered to be printed.
Mr. Elkins, from the Committee on Interstate Commerce, submitted
the following
ADVERSE REPORT.
[To accompany S. 423.]
The Committee on Interstate Commerce, to which was referred
Senate bill 423 "To amend section 6 of an act entitled 'An act to
regulate commerce,' approved February fourth, eighteen hundred
and eighty-seven, and acts amendatory thereof," respectfully reports
said bill adversely, and recommends its indefinite postponement.
The amendment proposed to section 6 will be found on page 4,
commencing on line 10, and ending on page 5, on line 8, of the bill,
as follows:
Provided further, That at any time prior to the expiration of the notice
herein required to be given of a proposed increase of rates, fares, or
charges, or of joint rates, fares, or charges, any shipper or any number of
shippers, jointly or severally, may file with the commission a protest, in
writing, against the proposed increase in whole or in part, stating
succinctly the grounds of his or their objections to the proposed change.
The filing of such protest shall operate to continue in force the then
existing rate or rates, fare or fares, charge or charges, proposed to be
changed and protested against as aforesaid, until the reasonableness of
the rate or rates, fare or fares, charge or charges, proposed to be
substituted shall have been determined by the commission. Upon the
filing of such protest, a copy thereof shall be mailed by the Secretary of
the commission to the carrier or carriers proposing the change and
thereafter the commission shall proceed to hear and determine the matter
in all respects as it is required to do by sections thirteen and fifteen of this
act, in case of a complaint made because of anything done or omitted to
be done by any common carrier, as provided in said section thirteen; but
throughout the proceeding, the burden of proof shall be on the carrier
proposing the change to show that the rate, fare or charge proposed to be
substituted is just and reasonable.
An amendment was offered in the committee which would modify
the original proposition of the amendment, by leaving it to the
discretion of the Interstate Commerce Commission, upon the filing of
a protest against the proposed increase of rates, to determine
whether the schedule filed should go into effect at the end of thirty
days or should be suspended by order of the commission until after
final hearing, upon the question as to whether the advance was
reasonable.
This proposed amendment to the amendment of the 6th section,
although somewhat modifying its effect, did not alter the principle
upon which the original amendment rested, or remove the
objections that influenced the committee in reporting the bill
adversely. The reasons which control the action of the committee
may be briefly stated as follows:
This case simply illustrates the fact that the court was unwilling to
decide the question finally until the rate contested had become
effective. This was a suit involving a schedule of rates, and the
question made by the record was that these rates would result in the
confiscation of the property of the complainant in violation of the
Federal Constitution. Where that question can be properly made, the
courts have intervened upon clear proof and sustained their
jurisdiction to prevent such a violation of the constitutional
protection. In this case, although the court held that the evidence
developed the fact that this allegation of the bill was not sustained,
it was so reluctant to give effect to testimony as to what might be
the effect of the rates before they were made operative that it
preserved the rights of the parties by authorizing a new suit after
the rate should become effective. Under the act to regulate
commerce, such a constitutional question could hardly be practically
raised, and the rights of the court to intervene must depend upon
the limit placed upon the power of the commission by Congress in
the enactment of the law, in fixing the standard which should guide
the commission in its action.