Answered step by step
Verified Expert Solution
Question
1 Approved Answer
7 . 2 3 LAB: Flip a coin Define a function named CoinFlip that returns Heads or Tails according to a random value 1 or
LAB: Flip a coin
Define a function named CoinFlip that returns "Heads" or "Tails" according to a random value or Assume the value represents "Heads" and represents "Tails". Then, write a main program that reads the desired number of coin flips as an input, calls function Coinflipo repeatedly according to the number of coin flips, and outputs the results. Assume the input is a value greater than
Hint: Use the modulo operator to limit the random integers to and
Ex: If the random seed value is and the input is:
the output is:
Tails
Heads
Tails
Note: For testing purposes, a pseudorandom number generator with a fixed seed value is used in the program. The program uses a seed value of during development, but when submitted, a different seed value may be used for each test case.
The program must define and call the following function:
string CoinFlip:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started