Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Cant figure out the coin flip.
#21
Andy, I analysed and tested your code and found what was wrong, so I interchaged the two IF's. Now it works.
Code:
DEFINT A-Z
RANDOMIZE TIMER

input a
for i = 1 to a
    flip = int(rnd * 2) + 1
    if flip = 1 then  'Tails=1, Heads=2
      t = t + 1
      if maxt < t then maxt = t   'modified
      h = 0
    else
       h = h + 1
       if maxh < h then maxh = h  'modified
       t = 0
    end if
next i
print "Consecutive heads: "; maxh;" consecutive tails: ";maxt
*****
Reply
#22
I highly appreciate all your help! I have one more question, how should I get the program to run so that it shows the coin flips? For example:

If I say flip the coin 7 times....I need it to show:
Tails
Heads
Heads
Tails
Heads
Tails
Tails

And then:
Consecutive heads: 2 Consecutive tails: 2
hane Martin
Reply
#23
in the IF statment that adds to each one
Code:
if flip = 1 then
...
print "tails"
else
...
print "heads"
end if
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#24
Yeah, thanks, Whitey.
*****
Reply
#25
Quote:Yeah, thanks, Whitey.
*****
Confusedhifty:
You talken to meh? =P Hehe...
...
AHH DE JA VU!
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#26
I appreciate everyone's help, I have turned in the program and got everything right like it was suppose to be, THANKS!!!
hane Martin
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)