Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

c++ help please! 2 seperate code/program needed, one that will implement the Coi

ID: 3670850 • Letter: C

Question

c++ help please!

2 seperate code/program needed, one that will implement the Coin class, one that will implement the main program that uses it.

2 individual programs that if put together will work

1. the first one is to Design a class named Coin (use a UML diagram).

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.
• 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.

2. the other is to create a game program that uses the Coin class. 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 $0. During each round of the game, the program will toss the simulated coins. 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 $1 or more. If your balance is exactly $1, you win the game. You lose if your balance exceeds $1.

What to turn in:

the implimented class in (.cpp, .h files) and one main program (.cpp) and the UML design (.jpg)

Explanation / Answer

Hi below i written a sample coin toss example for your reference,

#include <stdio.h>

#include <stdlib.h>

using std::cout;

using std::cin;
using std::endl;
using std::setw;

int flip_coin();

int main ()
{
unsigned seed;
int flip =1;
cout<<"Enterseed:";
cin>> seed;
srand ( seed);

cout<<"Heads"<<setw(15)<<"Tails"<<endl;

for(flip =1; flip <=100; flip++)
{
[red]// Get the result from the call to flip_coin first and
// then determine how to format your output and display the result
// based on that.[/red]
cout<<flip<< flip_coin()<<endl;
}
return 0;

}

int flip_coin(void)
{
return rand()%2;
}

#include <stdio.h>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote