*C++ CODE* * Complete the following code using C++ to meet…

Question Answered step-by-step *C++ CODE* * Complete the following code using C++ to meet… *C++ CODE* * Complete the following code using C++ to meet the requirements* I want to implement a game of tossing a coin  using C++ language and my program. Coin toss game in C++The game begins with m participants and n points.Each of the m players tosses a fair coin, resulting in some players’ coins showing heads and others showing tails. There are three possible outcomes:1) The number of heads on coins is smaller than the number of tails on coins.2) The number of heads on the coins equals the number of tails on the coins.3) the number of coins that show heads is greater than the number coins that show tails.. If the first event occurs, each player who has a heads coin loses 1/2 of their points and each player who has a tails coin earns one point. In this case, use an integer. If a player loses all of his or her points, the game is over.If the second scenario occurs, the players’ points remain unchanged.If the third event occurs, each player who has a heads coin earns one point and each person who has a tails coin loses half of their points. If a player loses all of his or her points, the game is over.The coin tossing cycle continues until only two players are left. The player who scores the most points is the winner. Both players win if the two players have the same number of points.  using namespace std;// Implements a game of double-or-nothing heads-or-tails, and explores a betting system.// Rules of double-or-nothing heads-or-tails:// – Player places bet from available money.// – Coin is flipped.// – If coin is heads: player receives 2x bet// – If coin is tails: player loses bet// – Lose condition: player runs out of money// – Win condition: player leaves with goal amount of money// Rules of betting system:// – Player has goal of making X dollars.// – Player bets goal of X dollars at start.// – If player wins bet, they leave & win.// – If player loses bet, they bet the lesser of either://       – Sum of losses & goal, or their entire available money supply// – If player has no money they lose.// Betting System Exploration:// – Take user inputs: //      – Available money to player at start//      – Player goal earnings// – Produce outputs://      – Average game length  //      – Probability that player will win vs. lose//        – Average Winnings per Game//        – Average Losses per Game//        – Expected Value of Playing Gamestruct game_result{    int rounds_played; // length of game      bool isWin; // true if win, false if loss};// Rules of double-or-nothing heads-or-tails:// – Player places bet from available money.// – Coin is flipped.// – If coin is heads: player receives 2x bet// – If coin is tails: player loses bet// Inputs: int bet – the amount of money that the player is betting// Outputs: int – the total amount of money returned to the player after the round is playedint play_round(int bet){  // Say heads are even, tails are odd from rand()  if (rand() % 2 == 0)  {      // Coin came up heads    // TODO  }    //TODO  return 0;}// Rules of betting system:// – Player has goal of making X dollars.// – If player wins bet, they leave & win.// – If player loses bet, they bet the lesser of either://       – Sum of losses & goal, or their entire available money supply// – If player has no money they lose.//  Inputs://      – int start_money – avaiable money to player at start//      – int goal_earnings – goal net winnings for player winnings//  Outputs://      – game_result – result of the gamegame_result play_game(int start_money, int goal_earnings){      // Sets up a variable to hold the results of the game.  struct game_result result;    // Sets up a variable to store the current amount that the player has in their money supply.  int current_money = start_money;     // Sets up a variable to store the total amount the player would have in their  // money to leave the game with a win.  int goal_money = start_money + goal_earnings;    // Sets up variables to hold temporary values within the loop  // TODO    // Sets up a loop to play multiple rounds  while (current_money > 0)  {    // Checks if the player has won their goal, so the win can be recorded.    if (current_money >= goal_money)    {      result.isWin = true;          }  }    }int main(){      // Initialize variables to store user inputs.      int start_money = 0;    int goal_earnings = 0;      int simulations = 1;          // Request user inputs    cout << "Please enter the money the player has at the start: ";    cin >> start_money;        cout << "";      cin >> ______;      cout << "";      cin >> ______;      // Print user inputs, w/ all variables    ______      // Sets up the random generator    _____(0); //The function should be 5 characters long        // Sets up variables for required summary statistics from simulations.          return 0;} Computer Science Engineering & Technology C++ Programming CIS 552 Share QuestionEmailCopy link Comments (0)