Your SlideShare is downloading. ×
Laboratory activity 3 b1
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Laboratory activity 3 b1

532

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
532
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
14
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Laboratory Activity 3 (Batch 1) Coin Toss Problem Write a windows application program that stimulates coin tossing. Let the program toss the coin each time the user presses the Toss Button. Count the number of times each side of the coin appears. Display the results. The program should call a separate method Flip(), with no arguments and return True for Heads, and False for Tails. Public Class Form1 Public HeadCount As Integer = 0 Public TailCount As Integer = 0 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click If Flip() Then HeadCount = HeadCount + 1 Label1.Text = "Heads: " & HeadCount Else TailCount = TailCount + 1 Label2.Text = "Tails: " & TailCount End If End Sub Function Flip() As Boolean Dim objRandomNumber As Random = New Random Dim randomNumber As Integer randomNumber = objRandomNumber.Next(1, 3) If randomNumber = 1 Then Return True Else Return False End If End Function End Class

×