0

Hey i was trying to do a coin simulate that tells you how many heads / tails it appears and that every time heads pops up you gain $2.00 (win) and whenever tails pops up (lose) you lose $1.00. My program does not print the winnings i do not know why. Thanks

```
#include <iostream>
using namespace:std;
#include <iomanip>
using std: setprecision;
#include <cstdlib>
#include <ctime>
int main()
{
double heads = 0;
double tails = 0;
int coin;
srand (time(0) );
for (int flip = 1; flip <= 10; flip++) {
coin = 1 +rand()%2;
switch (coin) {
case 1:
++heads;
break;
case 2:
++tails;
break;
default:
cout <<"?";
}
}
cout <<"Heads was flipped "<<heads<<" times"<<endl;
cout <<"Tails was flipped "<<tails<<" times\n"<<endl;
return 0;
}
void calculateTotal(double heads, double tails)
{
double win = heads * 2;
double lose = tails * 1;
double total = heads - tails;
if (total > 0)
cout <<"Congratulations you have won $ "<<total<<endl;
else
cout <<"Sorry you lost"<<endl;
}
```

*Edited 3 Years Ago by mike_2000_17*: Fixed formatting