To Notes

Lecture Summary for IT 236 on 6/29/05

 

Review Questions

  1. Show the variable trace and predict the output. Test your answer using VB.NET.
    Public Sub Main()
        Dim x, y As Integer
        Dim s, t As String

        x = 0
        y = 1
        s = "abcdefghijklmnopqrstuvwxyz"
        t = ""
        While x <= 25
           t = t & s.Substring(x, y)
           x = 2 * x + 1
        End While
        s = t.Insert(3, "***")
        WriteLine(s & x & y)
    End Sub

    Ans: Trace table:
    x y s t
    0 1 "abcdefghijklmnopqrstuvwxyz" ""
    1 1 "abcdefghijklmnopqrstuvwxyz" "a"
    3 1 "abcdefghijklmnopqrstuvwxyz" "ab"
    7 1 "abcdefghijklmnopqrstuvwxyz" "abdh"
    15 1 "abcdefghijklmnopqrstuvwxyz" "abdhp"
    31 1 "ab***dhp" "abdhp"

    Output:
    ab***dhp311

  2. Show the variable trace and predict the output. Test your answer using VB.NET.
    Public Sub Main( )
        Dim a( ) As Integer = {6, 2, 3}
        Dim t As Integer

        If a(0) > a(1) Then
           t = a(1)
           a(1) = a(0)
           a(0) = t
        End If

        If a(1) > a(2) Then
           t = a(2)
           a(2) = a(1)
           a(1) = t
        End If

        If a(0) > a(1) Then
           t = a(1)
           a(1) = a(0)
           a(0) = t
        End If

        For Each t In a
           WriteLine(t)
        Next
    End Sub

    Ans: Trace table:
    a(0) a(1) a(2) t
    6 2 3  
    2 6 3 2
    2 3 6 3
    Output:
    2
    3
    6

  3. Write a console application that counts how many blanks there are in an input string s.

    Ans: See the CountBlanks example.

  4. Write a console application that reads strings from an input file and writes them out reversed to an output file.

    Ans: See the Reverse1 example.

  5. Write a user defined function that inputs a string and returns the reversed string. Write a Main method to test your function.

    Ans: See the Reverse2 example.

  6. Write user defined functions according to the following specifications. Test each function in the Console Application Main method.

    1. Write a function named vowelCount that returns the number of vowels in a string.

      Ans: See the VowelCount.

    2. Write a function named IsFourLetter word. It should return True if the length of the input string is four. It should return and False otherwise.

      Ans: See the IsFourLetterWord.

  7. Write a For loop that adds the strings "A", "B", "C", ... , "Z", one per line, to a multiline text box.
    Hint: the ascii codes of these letters are 65 to 90. Use the Chr function that changes an ascii code into a character.

 

Introduction to Relational Databases

 

Some ADO.NET Objects for Database Processing

 

Using ADO.NET OleDb Data Objects

Method 1: Method 2: Method 3:  

Practice Problem

  1. Redo the PhoneNumbers Example using the database PhoneNumbers.mdb in PhoneNumbers.zip.

 

Two New Controls

 

The FlightInfo2 Project

 

The Random Object

 

Practice Problems

  1. Write a Console application that simulates 60,000 rolls of a die. Count how many sixes are obtained.

    Ans: See the DieRolls (W) example.

  2. Write a Console application that rolls a pair of dice repeatedly. Count how many rolls are needed to roll snake eyes (a pair of ones).

    Ans: See the SnakeEyes (W) example.

 

Drawing in a PictureBox Control

 

Capturing Mouse Data

 

Creating Controls Dynamically