SlideShare uma empresa Scribd logo
1 de 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

Mais conteúdo relacionado

Destaque (6)

GE LED Lamps - Portfolio presentation
GE LED Lamps - Portfolio presentation GE LED Lamps - Portfolio presentation
GE LED Lamps - Portfolio presentation
 
GE LED Tubes - Product presentation
GE LED Tubes - Product presentationGE LED Tubes - Product presentation
GE LED Tubes - Product presentation
 
Age verification
Age verificationAge verification
Age verification
 
Gastronomiebeleuchtung - Gleneagles Hotel
Gastronomiebeleuchtung - Gleneagles HotelGastronomiebeleuchtung - Gleneagles Hotel
Gastronomiebeleuchtung - Gleneagles Hotel
 
Software process models
Software process modelsSoftware process models
Software process models
 
INTERNATIONAL INDEXED REFEREED RESEARCH PAPER
INTERNATIONAL INDEXED REFEREED RESEARCH PAPERINTERNATIONAL INDEXED REFEREED RESEARCH PAPER
INTERNATIONAL INDEXED REFEREED RESEARCH PAPER
 

Semelhante a Laboratory activity 3 b1

Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2Jomel Penalba
 
Romero Blueprint Compendium
Romero Blueprint CompendiumRomero Blueprint Compendium
Romero Blueprint CompendiumUnreal Engine
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxpriestmanmable
 
Lập Trình VBA For Excel Tại Biên Hòa
Lập Trình VBA For Excel Tại Biên HòaLập Trình VBA For Excel Tại Biên Hòa
Lập Trình VBA For Excel Tại Biên HòaTrần Đình Ngọc
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docxcorbing9ttj
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docxcorbing9ttj
 
Lampiran source code
Lampiran source codeLampiran source code
Lampiran source codeancunk
 
Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008atsumagaysay
 
Inventory management
Inventory managementInventory management
Inventory managementRajeev Sharan
 
IHTM Python PCEP Hello World
IHTM Python PCEP Hello WorldIHTM Python PCEP Hello World
IHTM Python PCEP Hello WorldIHTMINSTITUTE
 

Semelhante a Laboratory activity 3 b1 (20)

Laboratory activity 3 b2
Laboratory activity 3 b2Laboratory activity 3 b2
Laboratory activity 3 b2
 
Vb file
Vb fileVb file
Vb file
 
Correction s+ rie_vb
Correction s+ rie_vbCorrection s+ rie_vb
Correction s+ rie_vb
 
Docimp
DocimpDocimp
Docimp
 
Romero Blueprint Compendium
Romero Blueprint CompendiumRomero Blueprint Compendium
Romero Blueprint Compendium
 
Stop watch and array
Stop watch and arrayStop watch and array
Stop watch and array
 
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docxISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
ISTA 130 Lab 21 Turtle ReviewHere are all of the turt.docx
 
Vbreport
VbreportVbreport
Vbreport
 
Vb.net programs
Vb.net programsVb.net programs
Vb.net programs
 
Lập Trình VBA For Excel Tại Biên Hòa
Lập Trình VBA For Excel Tại Biên HòaLập Trình VBA For Excel Tại Biên Hòa
Lập Trình VBA For Excel Tại Biên Hòa
 
1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx1. Determine the output displayed when the button is clicked.Priva.docx
1. Determine the output displayed when the button is clicked.Priva.docx
 
1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx1. Determine the output displayed when the button is clicked. Priv.docx
1. Determine the output displayed when the button is clicked. Priv.docx
 
Lampiran source code
Lampiran source codeLampiran source code
Lampiran source code
 
While loop
While loopWhile loop
While loop
 
UtilityCostCalcCode
UtilityCostCalcCodeUtilityCostCalcCode
UtilityCostCalcCode
 
Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008Linear Search Program in Visual Basic 2008
Linear Search Program in Visual Basic 2008
 
Inventory management
Inventory managementInventory management
Inventory management
 
VB net lab.pdf
VB net lab.pdfVB net lab.pdf
VB net lab.pdf
 
ملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعةملخص البرمجة المرئية - الوحدة الرابعة
ملخص البرمجة المرئية - الوحدة الرابعة
 
IHTM Python PCEP Hello World
IHTM Python PCEP Hello WorldIHTM Python PCEP Hello World
IHTM Python PCEP Hello World
 

Mais de Jomel Penalba

SE - Software Requirements
SE - Software RequirementsSE - Software Requirements
SE - Software RequirementsJomel Penalba
 
Requirements Engineering Process
Requirements Engineering ProcessRequirements Engineering Process
Requirements Engineering ProcessJomel Penalba
 
Copy of business hardware
Copy of business hardwareCopy of business hardware
Copy of business hardwareJomel Penalba
 
Business functions and supply chains
Business functions and supply chainsBusiness functions and supply chains
Business functions and supply chainsJomel Penalba
 
Ch5 - Project Management
Ch5 - Project ManagementCh5 - Project Management
Ch5 - Project ManagementJomel Penalba
 
Laboratory activity 3 b3
Laboratory activity 3 b3Laboratory activity 3 b3
Laboratory activity 3 b3Jomel Penalba
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2Jomel Penalba
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1Jomel Penalba
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programmingJomel Penalba
 
02 intro to vb-net ide
02 intro to vb-net ide02 intro to vb-net ide
02 intro to vb-net ideJomel Penalba
 
Soft Eng - Software Process
Soft  Eng - Software ProcessSoft  Eng - Software Process
Soft Eng - Software ProcessJomel Penalba
 
Soft Eng - Introduction
Soft Eng - IntroductionSoft Eng - Introduction
Soft Eng - IntroductionJomel Penalba
 
Planning Your Multimedia Web Site
Planning Your Multimedia Web SitePlanning Your Multimedia Web Site
Planning Your Multimedia Web SiteJomel Penalba
 

Mais de Jomel Penalba (20)

SE - System Models
SE - System ModelsSE - System Models
SE - System Models
 
SE - Software Requirements
SE - Software RequirementsSE - Software Requirements
SE - Software Requirements
 
Requirements Engineering Process
Requirements Engineering ProcessRequirements Engineering Process
Requirements Engineering Process
 
Copy of business hardware
Copy of business hardwareCopy of business hardware
Copy of business hardware
 
Business hardware
Business hardwareBusiness hardware
Business hardware
 
Crm
CrmCrm
Crm
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Business functions and supply chains
Business functions and supply chainsBusiness functions and supply chains
Business functions and supply chains
 
12 gui concepts 1
12 gui concepts 112 gui concepts 1
12 gui concepts 1
 
Ch5 - Project Management
Ch5 - Project ManagementCh5 - Project Management
Ch5 - Project Management
 
Laboratory activity 3 b3
Laboratory activity 3 b3Laboratory activity 3 b3
Laboratory activity 3 b3
 
06 procedures
06 procedures06 procedures
06 procedures
 
05 control structures 2
05 control structures 205 control structures 2
05 control structures 2
 
04 control structures 1
04 control structures 104 control structures 1
04 control structures 1
 
03 intro to vb programming
03 intro to vb programming03 intro to vb programming
03 intro to vb programming
 
02 intro to vb-net ide
02 intro to vb-net ide02 intro to vb-net ide
02 intro to vb-net ide
 
01 intro to vb-net
01 intro to vb-net01 intro to vb-net
01 intro to vb-net
 
Soft Eng - Software Process
Soft  Eng - Software ProcessSoft  Eng - Software Process
Soft Eng - Software Process
 
Soft Eng - Introduction
Soft Eng - IntroductionSoft Eng - Introduction
Soft Eng - Introduction
 
Planning Your Multimedia Web Site
Planning Your Multimedia Web SitePlanning Your Multimedia Web Site
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