Question: Problem Statement: Create a program with four functions that displays a menu and presents the user with the choices shown below. Menu choices: 1. Flip





Problem Statement: Create a program with four functions that displays a menu and presents the user with the choices shown below. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: In your program, there should be four functions: main() menu() coin() die() menu() is to display the menu choices shown as above; Choice 1: Flip a coin Ask the user how many times a coin should be flipped. Simulate flipping (tossing) the coin that number of times. Count the number of heads and the number of tails. Your output should resemble that shown below. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 1 How many flips do you want: 3546 The total flips are 3546. Head: 1733. Tail: 1813. Choice 2: Roll die Ask the user how many times a die should be rolled. Simulate rolling the die that number of times. Count the number of ones, two, threes, fours, fives, and sixes rolled. Calculate the percentage of each (save 2 digits after decimal point). Your output should resemble that shown below. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 2 How many rolls do you want: 3254 The total rolls: 3254. One: 514 times, Probability: 15.00% Two: 544 times, Probability: 16.00% Three: 561 times, Probability: 17.00% Four: 574 times, Probability: 17.00% Five: 542 times Probability: 16.00% Six: 519 times, Probability: 15.00% Choice 3: Quit the program The program should terminate normally when the user chooses to quit. This means that the main programming loop should terminate and flow of control in the main function will execute the return 0 statement. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 3 Main Menu choices other than 1, 2, or 3 should generate an error message, like the one shown below. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 4 Menu choice 4 not available. Please re-enter. Let us see the whole outputs from the beginning as follows in next page. main Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 1 How many flips do you want: 3546 The total flips are 3546. Head: 1733. Tail: 1813. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 2 How many rolls do you want: 3254 The total rolls: 3254. One: 514 times, Probability: 15.00% Two: 544 times Probability: 16.00% Three: 561 times, Probability: 17.00% Four: 574 times Probability: 17.00% Five: 542 times Probability: 16.00% Six: 519 times, Probability: 15.00% Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 4 Menu choice 4 not available. Please re-enter. Menu choices: 1. Flip a coin 2. Roll die 3. Quit program Enter menu choice: 3 Thanks for using my program. Please enjoy! Hint: You need rand() function in the directives #include
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
