Introduction: Batch File Heads or Tails Generator

Picture of Batch File Heads or Tails Generator

Code for a random heads or tails generator.

  1. Open notepad
  2. Copy code below
  3. Save it as ht.bat and click TEXT DOCUMENT and change it to ALL FILES
  4. Click save

@echo off

:top

cls

echo To flip the coin press enter

set /p enter=

set /a a=%random% %% 2+1

if %a% EQU 1 (

echo Heads pause goto top

)else echo Tails pause goto top

Comments

I_boom5245 (author)2015-10-15

I have made a new version of this for every one. Copy and paste this code:

@echo off

cls

:loop

cls

set /a a = 0

set /a b = 0

:game

cls

set /p ht= Press enter to flip the coin.

echo KACHING!!!

pause

set /a th = %random% %% 2+1

if %th% == 1 (

goto c

)else if %th% ==2 (

goto d

)else goto game

:c

cls

echo HEADS

echo.

echo -------------------

echo.

set /a a = %a% + 1

echo Heads: %a%

echo Tails: %b%

pause

goto game

:d

cls

echo TAILS

echo.

echo --------------------

echo.

set /a b = %b% + 1

echo Heads: %a%

echo Tails: %b%

pause

goto game

DIY Hacks and How Tos (author)2015-10-10

Nice way to make a decision.

About This Instructable

497views

3favorites

Bio: I like to computer program. I like soccer.
Add instructable to: