Download CISA 1310

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Line (geometry) wikipedia , lookup

Transcript
CISA 1310
Spring, 2004 – Exam #1
Part A
Name:_________________________
Write the Visual Basic code required to do each of the following: (4 points each)
1. Create storage for a variable to be used to hold a whole number in the range -200 to
+200
2. Create storage for a variable that will contain a person’s name.
3. Create storage to store a social security number.
4. Display the social security number from #3 in a listbox.
5. Add 43 to the number defined in #1
6. Find the average of all whole numbers from 0 through 7 and assign the average to the
variable defined in #1.
7. Insert your name as a comment on a line of a program.
8. Assign your name to the variable defined in #2.
CISA 1310
Spring, 2004 – Exam #1
Part B
Name:_________________________
1. Indicate which of the following are valid variable names in Visual Basic? (5 points)

myName

rent+taxes

test9

9test

A
2. What is the result of calculation of each of the following numeric expressions where
a=2, b=3, and c=4? (5 points)

(a * b) + c

a * (b + c)

(1 + b) * c

a^c

a + b / c^a
3. What output will result from each of the following code segments? (4 points)
Dim amount As Double
amount = 10
lstOutput.Items.Add(amount – 4)
Dim x As Double
tax = 200
tax = 25 + tax
lstOutput.Items.Add(tax)
4. For each of the following indicate the value of the valid function usage. If the
expression is invalid VB code indicate by the word “invalid”. (5 points)

Int(12.98)

Math.Int(12.98)

Math.Sqrt(81)

Math.Round(2.7)

Math.Round(-2.7)
5. Determine the output displayed in the textbox or listbox by each of the following
lines of code. NOTE: All of these are valid VB code. (4 points)

Dim var As Double
var = 123
txtBox.Text = Cstr(var + 5)

Dim num As Double
txtBox.Text = “5”
num = 0.5 + Cdbl(txtBox.Text)
txtBox.Text = Cstr(num)
6. In the code below, explain what each line does. (10 points)
Dim quote, person, qMark as String
quote = “We’re all in this alone.”
person = “Lily Tomlin”
qmark = Chr(34)
txtbox.Text = qMark & quote & qMark & “ – “ & person
7. Determine the output produced by the following lines of code. (18 points)

txtOutput.Text = FormatNumber(-12.3456, 3)

txtOutput.Text = FormatNumber(12345)

txtOutput.Text = FormatCurrency(-1234567)

txtOutput.Text = FormatCurrency(1234.5)

txtOutput.Text = FormatPercent(0.075)

txtOutput.Text = FormtaPercent(3 / 4, 1)
8. Determine the output produced by the following code. Label columns so I can tell
exactly what your answer is. (10 points)

Dim fmtStr As String = “{0, -5} {1, 7}”
lstOutput.Items.add(fmtStr, 75, “Howdy”)

Dim fmtStr As String = “{0, 3} {1, 10}”
With lstOutput.Items
.Add(“This is interesting”)
.Add(fmtStr, “A”, “BC”)
End With