Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a computer programming (C++) course please and comments to code.thanks In the main function Create an instance of coin Flip the coin 20

This is a computer programming (C++) course please and comments to code.thanks In the main function Create an instance of coin Flip the coin 20 times using the coinToss function

image text in transcribed
Coin Toss Simulator Write a class named Coin. The Coin class should have the following member variable: . . A string named sideUp . The sideUp member variable will hold either "heads" or"tails" indicating the side of the coin that is facing up. The Coin class should have the following member functions: . A default constructor that randomly determines the side of the coin that is facing up ("heads" or "tails") and initializes the sideUp member variable accordingly. The random number generate should be initialize here also. . A void member function named toss that simulates the tossing of the coin. When the toss member function is called, it randomly determines the side of the coin that is facing up ("heads" or "tails") and sets the sideUp member variable accordingly. . A member function named getSideUp that returns the value of the sideUp member variable. Create ADT called Flip that has three members the number of heads, the number of tails, and total number of flips Create a function called coin Toss . Takes as input a Coin class . Use a for loop to toss the coin 20 times. Each time the coin is tossed, display the side that is facing up. . The program should keep count of the number of times heads is facing up and the number of times tails is facing up, and the total number of flips . Return the number of times heads if facing up and tails is facing up as a Flip ADT

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions

Question

=+what is the level of equilibrium income in the economy?

Answered: 1 week ago