Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. var flips = 0;
  2. var howmanyheads = 0;
  3. var howmanytails = 0;
  4. var howmanyheadsandtails = 0;
  5. var headstreak = 0;
  6. while((headstreak < 200)){
  7. flips = flips + 1;
  8. console.log(flips);
  9. var coinside = randomNumber(1, 2);
  10. if (coinside == 1) {
  11. var howmanytails = howmanytails + 1;
  12. // write("The Coin Fliped Tails");
  13. write("Tails = " + howmanytails);
  14. howmanyheadsandtails = howmanyheadsandtails + 1;
  15. headstreak = 0;
  16. // write("Headstreak = " + headstreak);
  17. }
  18. if (coinside == 2) {
  19. var howmanyheads = howmanyheads + 1;
  20. // write("The Coin Fliped Heads");
  21. write("Heads = " + howmanyheads);
  22. howmanyheadsandtails = howmanyheadsandtails + 1;
  23. var headstreak = headstreak + 1;
  24. // write("Headsteak = " + headstreak);
  25. }
  26.  
  27.  
  28. }
  29. write("Total Flips = "+ howmanyheadsandtails);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement