[solved]-Using C Write Program Simulates Flipping Coin Repeatedly Continues Three Consecutive Heads Q38986971
using c++ Write a program that simulates flipping a coinrepeatedly and continues until three consecutive heads
are flipped. At that point, your program should display the totalnumber of coin flips that were made
and the average number of heads flipped.
#1 – Write a function string getName() to read in the user’s namefrom the keyboard
#2 – Write a function char getGender() to read in the user’s genderfrom the keyboard
#3 – Write a function bool flipCoin() to flip the coin and returntrue for heads and false for tails
(refer to Blackboard for random number generation details)
#4 – Write a function float calcAverageHeads(int hcnt, int tcnt) tocalculate the
average of heads vs. total flips
#5 – Write a function void displayResults(int tcnt, float avg) tooutput the total flip
count and percentage total heads flipped
#6 – Write a function void printHeader(string labName, stringlabNumber) that
prints out your header information to the screen when your programruns. You must call this
function for this and subsequent labs.
Address male users as Mr. and female users as Ms.
INPUT/OUTPUT – should be formatted as follows – This representsthree possible example runs.
Examine each example run to ensure you have the properfunctionality. (Class heading should be
also displayed)
[example 1: don’t output this line. Each run will bedifferent]
Welcome to coin toss! Get 3 heads in a row to win!
What is your name? Big Shot
What is your gender(M/F)? M
Try to get 3 heads in a row. Good luck Mr. Big Shot!
Press <Enter> to flip
HEADs
Press <Enter> to flip
TAILs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
Press <Enter> to flip
TAILs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
It took you 8 tosses to get 3 heads in a row.
On average you flipped heads 75% of the time.
[example 2: don’t output this line. Each run will bedifferent]
Welcome to coin toss! Get 3 heads in a row to win!
What is your name? Ima Lucky
What is your gender(M/F)? f
Try to get 3 heads in a row. Good luck Ms. Ima Lucky!
Press <Enter> to flip
HEADs
Press <Enter> to flip
TAILs
Press <Enter> to flip
TAILs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
Press <Enter> to flip
TAILs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
It took you 9 tosses to get 3 heads in a row.
On average you flipped heads 67% of the time.
[example 3: don’t output this line. Each run will bedifferent]
Welcome to coin toss! Get 3 heads in a row to win!
What is your name? Two Left Thumbs
What is your gender(M/F)? X
What is your gender(M/F)? y
What is your gender(M/F)? m
Try to get 3 heads in a row. Good luck Mr. Two Left Thumbs!
Press <Enter> to flip
HEADs
Press <Enter> to flip
TAILs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
Press <Enter> to flip
HEADs
It took you 5 tosses to get 3 heads in a row.
On average you flipped heads 80% of the time.
Expert Answer
Answer to using c++ Write a program that simulates flipping a coin repeatedly and continues until three consecutive heads are flip… . . .
OR

