Sei sulla pagina 1di 4

WALTER SISULU UNIVERSITY

Faculty of Science, Engineering & Technology


School of Computing
Information Technology Department
SUBJECT NAME : DEVELOPMENT SOFTWARE 2

CODE : DEVS2/0; DEV2130

TEST : TEST 1
DATE : 29 MARCH 2011

DURATION : 2 HOURS (120 MINUTES)


MARKS : 50 MARKS

EXAMINERS : MS L V D MERWE

MODERATOR : MR M SASIKUMAR

NUMBER OF PAGES : 4 (INCLUDING COVER PAGE)

INSTRUCTIONS

• This is a closed book test.


• No student is allowed to borrow a pen, pencil, eraser, ruler, etc. from another
student during the test.
• All cell phones must be switched off.
• All questions must be answered on the paper provided.
• Ensure that your last name and student number appear at the top of each page
used.
• Please make sure that we can read your writing.
• This script must be handed in with your answer paper.

ANSWER ALL QUESTIONS

DO NOT TURN THE PAGE BEFORE BEING TOLD TO DO SO.

1
QUESTION 1 [ 10 marks ]

In each of these questions, only one of the possible choices (a, b, c or d) is the correct answer.
Write down the question number, followed by the letter of the correct answer:

1.1 An integrated development environment is an environment that contains all the features and
tools to ____________ your programs.
a. create
b. run
c. test
d. all of the above

1.2 The caption displayed in form1 can be changed to TEST by the following line of code:
a. form1.Title = “TEST”
b. form1.Name = “TEST”
c. form1.Text = “TEST”
d. none of the above

1.3 The value entered into a text box is stored in the following property of the control.
a. Name
b. Text
c. Font
d. TextAlign

1.4 You usually use a ________ control to accept or display information that can be changed while
the application is running.
a. button
b. text box
c. label
d. none of the above

1.5 The last line of the select case statement in VB.NET is


a. End Select
b. Case End
c. Select End
d. End Case

1.6 If Option Strict is On, the following is true


a. Variables declared as double cannot be assigned to the text property of a label
b. All variables must be converted to integer before they are assigned to the text property
of a label
c. Numeric variables must be rounded to 0 decimal places before they are assigned to the
text property of a label
d. All of the above

1.7 Which of the following For clauses can be used to access each character contained in the
strValue variable, character by character? The variable contains 15 characters.
a. For intIndex As Integer = 0 to 15
b. For intIndex As Integer = 0 to strValue.Length – 1
c. For intIndex As Integer = 1 to strValue.Length
d. For intIndex As Integer = 1 to strValue.Length – 1

1.8 Which of the following statements can be used to assign the seventh character in the variable
strWord, to strLetter?
a. strLetter = strWord.Substring(6)
b. strLetter = strWord.Substr(7, 1)
c. strLetter = strWord.Substring(7, 1)
d. None of the above

1.9 If the variable strName contains the value "THEMBISILE", the method strName.IndexOf("e") will
return ___________
a. -1
b. False
c. 2
d. 0
2
1.10 Which of the following methods can be used to determine whether the variable strNumber ends
with a 9?
a. strNumber.Ends("9")
b. strNumber.Last = "9"
c. strNumber.EndsWith(9)
d. strNumber.EndsWith("9")

QUESTION 2 [ 8 marks ]

In the following problem, the output must be displayed in a label called lblDisplay.
The value being tested is in a variable called numTest (type double). (Do not declare it).

Write the VB code to do the following:


If the value in numTest contains a 3 or 8 or 9, display 3 asterisks, but if numTest has a negative value,
display 5 asterisks. However, if the value is from 10 to 20, then seven asterisks must be displayed. If
numTest contains any other value, display 4 equal signs.

QUESTION 3 [ 6 marks ]

For each of the following, write down exactly what will be displayed in the list box called lstAnswer.
You may assume that Option Strict is OFF

2a.
Dim n as Integer = 7
n += 3
n = 2 * n
lstAnswer.Items.Add(n)

2b.
Dim num as Integer
num = 5
For i as Integer = num to (num * 2 – (num – 1))
lstAnswer.Items.Add(i)
Next

2c.
With lstAnswer.Items
.Add(“Mandla”.ToUpper)
.Add(“four”.Length)
.Add(“PROGRAMMING”.Substring(4,3))
.Add(“ 120 ”.Trim & “ km/h”)
End With

3
QUESTION 4 [ 26 marks ]

Thandi has a computer and printer and she makes extra money by printing assignments for her
friends.
She wants a program that will allow her to input her friend’s name, the number of black and white
pages to be printed and the number of colour pages to be printed. She charges 75c for a black and
white page and R1.50 for a colour page.
When she clicks a calculate button, the program must do the data validation shown below. If the data
is valid, the program must calculate and display, in a read-only text box, the total amount her friend
must pay for the printing.
The program must end when she clicks an exit button.
Data Validation:
1. If she enters anything other than a number for black and white pages or colour pages: display an
error message, do not perform the calculation and display 0 as the output.
2. The number of black and white pages and the number of colour pages must both be >= 0 and the
total number of pages must be >= 1. If invalid, display an error message, do not perform the
calculation and display 0 as the output.

DO THE FOLLOWING:

1. Draw the GUI for the form. Show the name of each control. [ 5 marks ]

2. Draw the VB structure chart for the program. [ 8 marks ]

3. Write the VB code for the Calculate Click event. [ 13 marks ]


* NB*: Use the same control names that you have shown in your GUI drawing.
You may assume that Option Explicit and Option Strict are ON

Potrebbero piacerti anche