In C++ please
Create a coin-flipping game. Ask the user how many times to flip the coin, and use the random function to determine heads or tails each time a coin is flipped. Assume the user starts with $50. Every time the coin is flipped calculate the total (heads +$10, tails -$10). Create another function to test if the user has gone broke yet (THIS FUNCTION MUST RETURN A BOOLEAN TRUE/FALSE VALUE). End the program when the user is broke or when the coin was flipped the number of times the user had specified.
Display:
1) how many times the coin was flipped,
2) the number of times “heads” was the result,
3) the number of times “tails” was the result, and
4) how much money the user has at the end
// C++ code
#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
// unction to test if the user has gone broke yet (THIS FUNCTION MUST RETURN A BOOLEAN TRUE/FALSE VALUE)
bool checkheadtail()
{
// check head
if(rand()%2==0)
return false;
// else tail
return true;
}
int main()
{
srand(time(NULL));
int countflip;
int countHead = 0;
int tails = 0;
int bet = 50;
cout << "Enter how many times coin should flip: ";
cin>>countflip;
for(int i=0 ; i<countflip;++i)
{
// (heads +$10, tails -$10)
if(!checkheadtail())
{
bet = bet + 10;
countHead = countHead + 1;
}
else
{
bet = bet - 10;
tails = tails +1;
}
}
cout<<"Total times Coins flipped : "<<countflip<<endl;
cout<<"Number of times 'heads': "<<countHead<<endl;
cout<<"Number of times 'tails': "<<tails<<endl;
cout<<"Money: $"<<bet<<endl;
return 0;
}
In C++ please Create a coin-flipping game. Ask the user how many times to flip the...
Simulate the flipping of a coin Print the result of the coin flip : use off numbers for Heads . and even numbers for Tails Update the number of times the result is Heads Update the number of times the coin has been flipped struct coin_prob{ int heads; int flips; }; void coin_flip(struct coin_prob * coin); You may use a rand functioon (assume its already been seeded), but no other pre-defined function
Problem 02 Design a finite-state machine that records the results of flipping a coin a certain number of times. The state machine takes as an input flip which is zero for heads and one for tails. The states are labeled so as to indicate the numbers of heads and the nurnber of tails, NONE. H. T, HH, TT HT, HHH, etc. The order that the heads or tails was flipped does not matter, only the total numbers of heads and...
Write a C program that prompts the user for the number for times the user wants to flip a coin. Your program will flip a virtual coin that number of times and return the following: 1) The number of times heads occurred. 2) The number of times tails occured. Then take the coin flip program and modify the random number generator to roll a single 6-sided dice. DO NOT DISPLAY THE RESULTS OF EACH ROLL. 1) Ask the user how...
please write clear and show work 19. A coin is flipped 10 times where each flip comes up either heads or tails. How many possible outcomes a) are there in total? b) contain exactly two heads? c) contain at most three tails? d) contain the same number of heads and tails?
Flip a coin 50 times, create a table to tally your results, then create a graph of your results to display the percentage of heads or tails.
In flipping a coin 12 times and observing heads or tails, how many different outcomes can be obtained?
casino Carl loves flipping coins. In fact, he is preparing to flip a coin 50 times and track how many heads he gets (from zero to 50) Casino Carl loves flipping coins. In fact,he is preparing to flip a coin 50 times and track how many heads he gets (from zero to 50). Use the normal approximation to find the probability Carl gets 20 heads or less from his 50 flips? Select one: a. 0.1563 b. 0.1014 C.0.0986 d. 0.0793
Please help me put this in order!! THANKYOU!! (CO 4 and 6) Create a program with a function named flipCoin that will flip a coin as many times as the user asks. The flipCoin function should return “heads” or “tails”. The program should continue while the user presses Y. SAMPLE OUTPUT: How many times do you want to flip a coin? 5 You got: tails You got: tails You got: tails You got: tails You got: heads To continue press...
Answer part a and part b please!!! (a) What is the conditional probability that exactly four Tails appear w when a fair coin is flipped six times, given that the first flip came up Heads? (I.e. the coin , then is flipped five more times with Tails appearing exactly lour times.) (b) What if the coin is biased so that the probability of landing Heads is 1/3? (Hint: The binomial distribution might be helpful here.) (a) What is the conditional...
Casino Carl loves flipping coins. In fact, he is preparing to flip a coin 50 times and track how many heads he gets (from zero to 50). Use the normal approximation to find the probability Carl gets 20 heads or less from his 50 flips?