Question
Answered step-by-step
I need help with wriiting this C++ program this a program that...

I need help with wriiting this C++ program this a program that simulates flipping a coin and rolling a dice.

1 Attachment
Write a program that simulates fipping a coin and rolling a dice. A user will input their choice oF fipping a coin (C), rolling a dice (D), or exiTng (E). IF the user chooses a coin toss, the program will ask how many Tmes the coin should be tossed, and then will simulate tossing the coin that many Tmes and print the result to the user. IF the user chooses rolling a die, the program will ask how many sides the die has and how many Tmes it should be rolled. ±he program will then simulate rolling a die (with the number oF sides speci²ed) that many Tmes. ±he program will conTnue unTl the user presses E. This should be a lot of fun! Here are some great things to think about as you begin your program! You will need two FuncTons. A string fipCoin() and a int rollDice(int) FuncTon . ±hese FuncTons will generate a random number. ³or the coin fip, the random number should be in the range oF 1 to 2. IF the number is 1, the FuncTon should return heads. IF the random number is 2, the FuncTon should return tails. ³or the roll dice FuncTon, the random number should be in the range oF 1 to the number oF sides. ±he FuncTon should return the result oF the die roll. Important notes: You will want to seed your random number generator. ±o do this at the beginning oF your program #include <cTme>. Use the Following commands to seed the random number generator. //Get the system Tme to use it to seed the random number generator unsigned seed = Tme(0); //seed the random number generator srand(seed); ±o get a random number between 1 and 2, use the Following code: int toss = 1 + rand() % 2;. Sample Output from the Program Welcome to the random value generator! Would you like to fip a coin (C), roll a die (D), or exit (E)? C How many Tmes do you want to fip the coin? 5 ³lip 1 : tails ³lip 2 : heads ³lip 3 : heads ³lip 4 : heads ³lip 5 : tails
Background image of page 1
3 pages
Answer & Explanation
Verified Solved by verified expert

gue vel laoreet ac, dictum vitae odio. Donec aliqu

cing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipis

Unlock full access to Course Hero

Explore over 16 million step-by-step answers from our library

Subscribe to view answer
Step-by-step explanation

a. Fusce dui lectus,

nec facilisis. Pellentesque dapibus efficitur laoreet. Nam risus ante, dapibus a molestie consequat, ultrices ac magna. Fusce dui lectus, congue vel laoreet ac, dictum vitae odio. Donec aliquet. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nam lacinia pulvinar tortor nec facilisis. Pellentesque d
1 Attachment
coin_dice.cpp
cpp
Student review
100% (1 rating)