akosiraff

Download CoinProject CPP

Dec 4th, 2014
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1.  
  2. Download: http://solutionzip.com/downloads/coinproject-cpp/
  3. Coin Toss Simulator
  4. Write a class named coin. The coin class should have the following member variable:
  5. A string named sideUp. The sideUp member variable will hold either “heads” or “tails” indicating the side of the coin that is facing up.
  6. The coin class should have the following member functions:
  7. 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.
  8. A void member function named toss that simulates the tossing of the coin. When thetoss 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.
  9. A member function named getSideUp that returns the value of the sideUp member variable.
  10. 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 kepp count of the number of times heads is facing up, and display those when the loop is finished.
  11. Download: http://solutionzip.com/downloads/coinproject-cpp/
Add Comment
Please, Sign In to add comment