Questions tagged [coin-flipping]

Coin flipping is the process of programmatically simulating a coin flip, that is randomly picking a choice among two possibilities.

Coin flipping is the process of programmatically simulating a coin flip, that is randomly picking a choice among two possibilities.

118 questions
-1
votes
2 answers

Java coin flip with user entered variables

I am trying to create a java program which accepts a user entered number and then flips a coin that many times and then displays how many heads or tails have been flipped so far. My problem comes when I can't figure out how to make the program flip…
-1
votes
1 answer

Three Heads in a row Java Program?

Write a program in JAVA that will simulate coin tosses and output the number of tosses required to get three “heads” in a row. This program will also output to the screen the “heads” and “tails” that it has simulated tossing. For example, your…
Jainam Patel
  • 33
  • 2
  • 2
  • 11
-1
votes
2 answers

JavaScript: How To Count Total Number Of Heads and Tails In Random Coin Flip Within Associative Array?

I have an array that has two other associative arrays within it: var coinToss = []; coinToss["FlipNumber"]; coinToss["Result"]; I already have the randomizer function working and everything. I just need help on totaling the sum of all 'heads'…
5120bee
  • 619
  • 1
  • 10
  • 28
-1
votes
2 answers

JavaScript: How To Code a Heads/Tails With Specific Probability Chance Percentage?

I've implemented the function: function coinFlip() { return(Math.floor(Math.random()*2) === 0) ? 'Heads' : 'Tails'; } And it's all working fine (I already tested it). My problem is, how do I make this function so that the probability of…
5120bee
  • 619
  • 1
  • 10
  • 28
-1
votes
1 answer

Distribute traffic by Making a biased toss to choose between ad networks in android?

I have made an android app and I want to show exit ad. I have 3 ad networks. I want to pass a parameter from server to choose between these networks. Lets say, I give edge to adnetwork 1 = 50% adnetwork 2, 40% dnetwork 3, 10% and I want to…
lightsaber
  • 1,411
  • 18
  • 36
-1
votes
3 answers

Append rle result from loop

I am running a coin-toss simulation with a loop which runs about 1 million times. Each time I run the loop I wish to retain the table output from the RLE command. Unfortunately a simple append does not seem to be appropriate. Each time I run the…
Frank Zafka
  • 799
  • 8
  • 29
-2
votes
2 answers

How to find the most frequent length of Heads in a Coin Toss?

I need to find out which is the most frequent length for heads series. If there are more than one most frequent heads series lengths, print the longest. If there are no heads in the trial, print zero. Example : Input : HTTHH Output : 2 Input :…
-2
votes
1 answer

coin toss in python, flips coin 1000 times, need to run it 3 times and find average

Here is what I have so far. The problem asks us to run coinToss(1000) a certain number of times. Then find the average number of heads based on the three times it ran. (e.g., If we got 400 heads, 350 heads, and then 600 heads, the program would…
user1681689
  • 1
  • 1
  • 4
-3
votes
1 answer

Counting the number of occurrences. (beginner)

Okay, I'm a beginner with java and struggling with the counter. I am trying to find the count and print the number of occurrences of both heads and tails of a flipped coin. When I run my code, it prints the occurrence of each event on every line. I…
-3
votes
2 answers

Coinflip until 50/50

"pretty new programmer here" i'm trying to do a coin-flip code that flips a coin 100 times and gives me the heads or tails total value, but i would want to keep fliping untill its 50/50. I have the coin-flip but i'm in an infinite loop i cant get…
-4
votes
2 answers

I am doing a coin toss game program. But i am having an error in this portion [ (if Guess==i) {. How do I solve this?

import java.util.Scanner; public class CoinTossGame { public static void main(String[] args) { System.out.println("A coin is tossed!"); int Heads=0, Tails=1; Scanner input = new Scanner (System.in); System.out.println("Enter…
-4
votes
2 answers

Coin flip program on c++

I am trying to make a program that will randomly show the outputs of a coin flipping until there are 5 heads in a row and then the program has to stop. I do not have a lot of experience coding so any help is appreciated! So far all I have is a…
Joshua Ayala
  • 7
  • 1
  • 2
-5
votes
1 answer

Random number generator gives consistent results

So the goal of my program is to simulate flipping a coin. I'm trying to use a random number generator to generate the number 1 or 2, 1 for heads, 2 for tails. However I keep getting Tails as the result, where am I going wrong? #include…
RavSon
  • 3
  • 3
1 2 3 4 5 6 7
8