Created
April 28, 2015 09:17
-
-
Save adnan360/03ba2e5950ba4a148a3e to your computer and use it in GitHub Desktop.
A script to make virtual coint tosses. You can just give how many coin tosses you want and the script will make that many coin tosses.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- title | |
io.write('** COIN TOSS SIMULATOR **\n\n') | |
-- take input | |
io.write('Please enter how many coin toss you want:') | |
num = io.read() | |
-- tossing | |
tails=0 | |
heads=0 | |
for i=1,num do | |
result = math.random(1,2) | |
if result == 1 then | |
io.write('head\n') | |
heads=heads+1 | |
else | |
io.write('tail\n') | |
tails=tails+1 | |
end | |
end | |
--total | |
io.write('-------------------------------\n') | |
io.write('Total result:\n') | |
io.write('Heads: ',heads,' \tTails; ',tails, '\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment