Question: Its two programs C++ Fall 2017 Program 10 Due 10 November 2017 This problem has two parts meaning two programs although one depends on parts
Fall 2017 Program 10 Due 10 November 2017 This problem has two parts meaning two programs although one depends on parts of the other. First write a class named Coin. The Coin class should have the following member variable: CSDP 222 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 accordingly . 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 acoordingly. . A member function named getSideUp that returns the value of the sideUp member variable. 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. Second, using the Coin class you just created, create a game program as follows: The program should have three instances of the Coin class: one representing a quarter, one representing a dime, and one representing a nickel. When the game begins, your starting balance is SO. During each round of the game, the program will When a coin is tossed, the value of the coin is added to your balance if it lands heads-up. For example, if the quarter lands heads-up, 25 cents is added to your balance. Nothing is added to your balance for coins that land tails-up. The game is over when your balance reaches SI or more. If your balance is exactly $1, you win the game. You lose if your balance exceeds SI. Output should be the running score of the tosses with appropriate language to make the output clear. A sentence indicating winning or losing and why or how much will be output, to0, toss the simulated coins
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
