SlideShare a Scribd company logo
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

More Related Content

PPTX
Understanding UNIX CASE and TPUT
DOCX
Ete programs
DOCX
เกมส์จับคู่
DOCX
Quiz 9 review sheet
PDF
EstimateExtraterrestrialLife
PDF
C Language Lecture 6
PDF
C2 Profile - Brochures & Calenders
PPTX
GE LED Plug-in 2Pin - Product Presentation
Understanding UNIX CASE and TPUT
Ete programs
เกมส์จับคู่
Quiz 9 review sheet
EstimateExtraterrestrialLife
C Language Lecture 6
C2 Profile - Brochures & Calenders
GE LED Plug-in 2Pin - Product Presentation

Viewers also liked (6)

PPTX
GE LED Lamps - Portfolio presentation
PPTX
GE LED Tubes - Product presentation
TXT
Age verification
PDF
Gastronomiebeleuchtung - Gleneagles Hotel
DOC
Software process models
GE LED Lamps - Portfolio presentation
GE LED Tubes - Product presentation
Age verification
Gastronomiebeleuchtung - Gleneagles Hotel
Software process models
Ad

Similar to Laboratory activity 3 b1 (20)

PDF
2 Python Basics II meeting 2 tunghai university pdf
DOC
Laboratory activity 3 b2
DOC
DOC
Correction s+ rie_vb
DOCX
Docimp
PPTX
Romero Blueprint Compendium
PDF
Stop watch and array
DOCX
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
DOCX
Vbreport
PDF
Lập Trình VBA For Excel Tại Biên Hòa
DOCX
1. Determine the output displayed when the button is clicked. Priv.docx
DOCX
1. Determine the output displayed when the button is clicked.Priva.docx
DOCX
Lampiran source code
PPTX
While loop
PDF
UtilityCostCalcCode
PDF
Linear Search Program in Visual Basic 2008
PDF
Inventory management
PDF
VB net lab.pdf
PPT
ملخص البرمجة المرئية - الوحدة الرابعة
2 Python Basics II meeting 2 tunghai university pdf
Laboratory activity 3 b2
Correction s+ rie_vb
Docimp
Romero Blueprint Compendium
Stop watch and array
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
Vbreport
Lập Trình VBA For Excel Tại Biên Hòa
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked.Priva.docx
Lampiran source code
While loop
UtilityCostCalcCode
Linear Search Program in Visual Basic 2008
Inventory management
VB net lab.pdf
ملخص البرمجة المرئية - الوحدة الرابعة
Ad

More from Jomel Penalba (20)

PPT
SE - System Models
PPT
SE - Software Requirements
PPT
Requirements Engineering Process
DOCX
Copy of business hardware
PPTX
Business hardware
DOC
Chapter 1
PPTX
Business functions and supply chains
PPT
12 gui concepts 1
PPT
Ch5 - Project Management
DOC
Laboratory activity 3 b3
PPT
06 procedures
PPT
05 control structures 2
PPT
04 control structures 1
PPT
03 intro to vb programming
PPT
02 intro to vb-net ide
PPT
01 intro to vb-net
PPT
Soft Eng - Software Process
PPT
Soft Eng - Introduction
PPT
Planning Your Multimedia Web Site
SE - System Models
SE - Software Requirements
Requirements Engineering Process
Copy of business hardware
Business hardware
Chapter 1
Business functions and supply chains
12 gui concepts 1
Ch5 - Project Management
Laboratory activity 3 b3
06 procedures
05 control structures 2
04 control structures 1
03 intro to vb programming
02 intro to vb-net ide
01 intro to vb-net
Soft Eng - Software Process
Soft Eng - Introduction
Planning Your Multimedia Web Site

Laboratory activity 3 b1

  • 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