Write a C++ program that simulates coin tossing. For each toss of the coin the program should print Heads or Tails. The program should toss a coin 100 times. Count the number of times each side of the coin appears and print the results at the end of the 100 tosses.
The program should have the following functions as a minimum:
- void toss() – called from main() and will randomly toss the coin and set a variable equal to the face of the coin
- void count() – called from toss to increment counter for heads or tails
- void displayCount() – is called from main() and will display the values of the counter for heads and the counter for tails.
If any global variables are used in the program, the program will receive a grade of 0.
So far what I have. Anything I should clean up? Also, I am confused on the global variables part specifically. Can you doublecheck to make sure I am not using any in the program. Any help is appreciated!! #include #include #include using namespace std; int totalCount=100; int headsCount=0; int currentCoinFace; void count() { if(currentCoinFace==0) { headsCount++; cout<>< =”” }=”” =”” else=”” =”” {=”” =”” =””><>< =”” }=”” }=”” void=”” toss()=”” {=”” =”” currentcoinface=”rand()” %=”” 2; =”” =”” count();=”” }=”” void=””>
{ cout
total=”” number=”” of=”” heads=”< cout<<” the=”” total=”” number=”” of=”” heads=””>