COMP 125: Introductory Programming

Course Examination

Test Date: Monday, April 12, 1999


Part I (10 points)

Determine the output displayed in the picture box when the command button is clicked:

  Private Sub Command1_Click()

Dim i as Integer, j as Integer
For i = 0 to 2
For j = 0 to 3
Picture1.Print i + 3 * j + 1; " ";
Next J
Picture1.Print
Next i
End Sub


Part II (10 points)

Identify the error in the following program segment:

    Private Sub Command1_Click()

Dim i As Integer, j As Integer
For i = 1 to 6
For j = 1 to 3
Picture1.Print i / j;
Next i
Next j
End Sub


Part III (30 points)

Rewrite the program using a For . . . Next loop.

  Private Sub_Command1_Click()
    Dim num As Integer
    Let Num = 1
    Do While num <= 10
       Picture1.Print num
       Let num = num + 2
    Loop
  End Sub


Part IV (50 points)

Supply and Demand. This year's level of production and price for most agricultural products greatly affects the level of production and price next year. Suppose the current crop of soybeans in a certain country is 80 million bushels and experience has shown that for eah year:

[price this year] = 20 - 0.1 * [quantity this year]

[quantity next year] = 5 * [price this year] - 10

where quantity is measured in units of millions of bushels. Generate a table to show the quantity and price for each of the next 12 years.

Please be sure to construct user-defined functions to carry out the calculations for quantity and price.


Do you have any questions, comments or suggestions? If so, please e-mail them to me at jcorlis@luc.edu.

To return to the COMP 125 web site, click here.

To go to my home page, click here.

To go to the home page of Loyola University Chicago, click here.


Jack Corliss
Mathematical and Computer Sciences
Loyola University Chicago
Revised: 15 January 1999