Uploaded by Thembani Thembani

Assignment2

advertisement
ASSIGNMENT 2
1.
2.
Unique no: 820537
3 Public Class Form1
Dim numMutl As Integer = 1
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
Me.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
ListBox1.Items.Clear()
ListBox1.Refresh()
TextBox1.Text = " "
numMutl = 1
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
Do While (numMutl <= 10)
ListBox1.Items.Add(numMutl & "*" & Val(TextBox1.Text) & "=" & numMutl *
Val(TextBox1.Text))
numMutl += 1
ListBox1.Refresh()
Loop
End Sub
End Class
4.
Declare Variable: 1stNum, 2ndNum, I, J As Integer
Initialize Values: 1stNum = me.txt1stNum.Txt, 2ndNum= me.txt2ndNum.Txt
Start Outer for Loop: For I = 0 to 3
Start Inner for Loop: For J = 0 to 2
Print me stars
Exit I
Exit J
Stop
5.
6.
FUNCTION T TestScoreTotal RETURNS Integer
DECLARE AnswerCorrect, Finish: BOOLEAN
DECLARE Number1, Number2, Score: INTEGER
Score = 0
//initiative Score
Finish ← FALSE
REPEAT
Number1← Random
//generate two
Number1← Random
//numbers
Display (Number1, Number2)
AnswerCorrect ← CheckAnswerCorrect (Number1, Number2)
IF AswerCorrect = True
THEN Score ← Score + 1
ELSE Finish = True
ENDIF
UNTIL Finish = True
RETURN Score
ENDFUNCTION
//was answer correct?
//flag set to stop program
// is flag set?
// return the number of
// questions answered correctly
Download