Monday, September 20, 2010

lecture 5 notes

some hints for assignments 2 and 3

assignment 2:
Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim degreeType As String
        degreeType = TextBox1.Text
        If degreeType = "Celsius" Then
            ' convert to other type

            ' output statement
        Else
            ' convert to other type

            ' output statement
        End If
    End Sub
End Class

assignment 3:
see the spreadsheet on Blackboard for the strategy

Loops:
Be careful about infinite loops

Public Class Form1

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim answer As String

        Do
            answer = InputBox("Pete and Repeat were on a boat. Pete fell off. Who was left?", "Important question", "Repeat")
        Loop While answer = "Repeat"
    End Sub
End Class

Assignment 4:
HW: Modify the above to count how many times the person chose "Repeat". Output this somewhere at the end.

HW: Your program requires a password to get into it. That password is "swordfish". At the start of your program, prompt for the password and keep asking them until they finally say "swordfish".

Due date: Next Wednesday

No comments:

Post a Comment