You are on page 1of 4

CMP 221

INTRODUCTION TO PROGRAMMING 1
ASSIGNMENT.
1. Explain in details what Array is in Programming
2. List and explain the types of Array with relevant examples.
What is the output of question 3 and 4 below?
3. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim num As Integer = 2
Dim spoon(num) As String
spoon(0) = "soup"
spoon(1) = "dessert"
spoon(2) = "coffee"
txtOutput.Text = "Have a "& spoon(num - 1) & " spoon."
End Sub
4. Private Sub btnDisplay_Click(...) Handles btnDisplay.Click
Dim a(20) As Integer
a(5) = 1
a(10) = 2
a(15) = 7
lstOutput.Items.Add(a(5) + a(10))
lstOutput.Items.Add(a(5 + 10))
lstOutput.Items.Add(a(20))
End Sub

5. Write a program that asks the user for a month by number and then displays the name of that
month. For instance, if the user inputs 2, the program should display February. Hint: Create an
array of 12 strings, one for each month of the year.

6. Write a program to compute a student's grade-point average for a semester. Allow for as many
as six courses. For each course, the grades (A, B,...) should be entered in an element of an array
of six text boxes, and the semester hours credits entered into another array of six text boxes.
After the student fills in the grades and clicks on a button, a Function procedure should compute
the GPA. Then a Sub procedure should display the GPA along with one of two messages. A
student with a GPA of 3 or more should be informed that he or she has made the honor roll.
Otherwise, the student should be congratulated on having completed the semester.

7. The table below gives the U.S. Census Bureau projections for the populations (in millions) of the
states predicted to be the most populous in the year 2025. Write a program that allows the user
to enter the current populations of the states into an array of text boxes, computes the
projected population growths for the states in an array of text boxes, and gives the percentage
growth for the collection of five states. The growth is calculated with the formula growth =
(projected pop. current pop.)/current pop.
8. Suppose the Integer array quantities() has been declared with an upper bound of 100 and data
have been placed into several elements of the array.
9. Write code to declare an array of size 20 and place the names Jerry, George, Elaine, and Kramer
into the first four elements. Use one or two lines of code.
10. Declare the string array marx() with upper bound 3 so that the array is visible to all parts of the
program. Assign the four values Chico, Harpo, Groucho, and Zeppo to the array before any
buttons are pressed.
11. Declare the string array stooges() to have size 3 so that the array is local to the event procedure
btnStooges_Click. Assign the three values Moe, Larry, and Curly to the array as soon as the
button is clicked.
12. The arrays a() and b() have been declared to have upper bound 4, and values have been
assigned to a(0) through a(4). Store these values in array b() in reverse order.
13. Given two arrays of type Double, p() and q(), each with upper bound 20, compute the sum of
the products of the corresponding array elements, that is,
p(0)*q(0) + p(1)*q(1) + p(2)*q(2) + ... + p(20)*q(20)
14. Study the table below carefully and fill in the blank spaces appropriately.

Property/ Method Description


 

Properties
Enabled Property used to enable a textbox control.
Index Property used to specify the index of a control array.
This property specifies whether you can edit data in a control in Form
Locked
view.
Property used to specify the maximum number of characters accepted
MaxLength
by a TextBox Control.
Returns or sets an Integer that specifies the type of pointer displayed
MousePointer
when the user positions the mouse over a particular object.
Multiline This property is used to set more than one line text
Mask This is to specify mask character to be displayed in the TextBox
This to set either the vertical scrollbars or horizontal scrollbars to
 ScrollBars make appear in the TextBox. User can also set it to both vertical and
horizontal. This property is used with the Multiline property.
Specifies the text to be displayed in the TextBox at runtime
RichTextBox This is used to display what text is displayed or in the control
By setting this user can make the Textbox control visible or invisible
Visible
at runtime
 
 
Method
Focus Transfers focus to the TextBox
 
 
Event procedures
Change Event occurs when the contents of the specified control change.
Click Action happens when the TextBox is clicked
GotFocus Action occurs when the specified object receives the focus.
.LostFocus Action happens when the TextBox loses it focus
KeyDown
KeyUp Called when a key is released while the TextBox has the focus

Submission date: 1st February, 2021 on Monday.


Time:-2:00pm.
Venue: - Department of Computer Science Office behind old physic laboratory.
Dim marks() As Integer
ReDim marks(2)
marks(0) = 85
marks(1) = 75
marks(2) = 90

You might also like