Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

this code is written in C++ Q2: Write a class named Coin. The Coin class should have the following member variables: A string named sideUp.

this code is written in C++
image text in transcribed
Q2: Write a class named Coin. The Coin class should have the following member variables: 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 variables accordingly. A void member function named toss that simulates the tossing of the coin. When the toss function is called, it randomly determines the side of the coin that is facing up ("heads" or "tails") and sets the side Up member variables accordingly. A member function named getSide Up that returns the value of the sideUp member variables. Write a program that demonstrates the Coin class. The program should create an instance of the class and display the side that is initially facing up. Then, use a 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 display those values after the loop finishes

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_2

Step: 3

blur-text-image_3

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

Advances In Spatial And Temporal Databases 10th International Symposium Sstd 2007 Boston Ma Usa July 2007 Proceedings Lncs 4605

Authors: Dimitris Papadias ,Donghui Zhang ,George Kollios

2007th Edition

3540735399, 978-3540735397

More Books

Students also viewed these Databases questions

Question

LO3 Name the seven categories of HR functions.

Answered: 1 week ago