# Help with roulette program

• 10-27-2003
clc529
Help with roulette program
I am trying to create 2 roulette wheels(american & european) The american wheel has numbers ranging from 1-36,0,& 00........the european wheel has numbers from 1-36 & 0 (the wheels are suppose to spin and give you a random number in those number ranges). The program is just suppose to run and NOT interact with the user. The bet is 6 random numbers which are \$1.00 each. I need to show the amount of money(won or lost) at spin 25..250..2,500..25,000..& 250,000. It's a console apt. Im stuck because when i run this program it shows the same thing twice and in the american column it shows 130130 and nothing in the european column. Please help thanks in advance.

Code:

```#include <iostream> #include <cstdlib> #include <iomanip> #include <stdlib.h> #include <cmath> using namespace std; void showArray (int [6][1][1], int); int getBet() {   int seed = 6;   int bet = 1 + (rand () % 38);   srand (seed);   return bet; } int getSpinA() {   int seed = 1;   int spin = 1 + (rand () % 38);   srand (seed);   return spin; } int getSpinE() {   int seed = 1;   int spin = 1 + (rand () % 37);   srand (seed);   return spin; } double money (100.00);                    //starting money int main() {   double  a, e, euro, total;   cout << (left) << setw (18) << "N" << setw (10) << "\$" << (right) << setw (5) << "e" << endl;   cout << "________________________________________" << endl;   for (int count = 0; count <= 250000; count++)   {       for (int play = 0; play <= 6; play++)       {           getBet();           getSpinA();           getSpinE();           total = money - 6.00;                //each bet is a dollar           euro = money - 6.00;           if ((count == 25)&& getBet() == getSpinA()|| getSpinE())                //win           {               a = total + 36.00;               e = euro + 36.00;               cout << (left) << setw (15) << "25" << a << e << endl;               if ((count == 25) && getBet() != getSpinA()|| getSpinE())            //lose               {                   cout << (left) << setw (15) << "25" << a << e << endl;                   if ((count == 250) && getBet() == getSpinA()|| getSpinE())                //win                   {                       a = total + 36.00;                       e = euro + 36.00;                       cout << (left) << setw (15) << "250" << a << e << endl;                       if ((count == 250) && getBet() != getSpinA()|| getSpinE())            //lose                       {                           cout << (left) << setw (15) << "250" << a << e << endl;                           if ((count == 2500) && getBet() == getSpinA()|| getSpinE())                //win                           {                               a = total + 36.00;                               e = total + 36.00;                               cout << (left) << setw (15) << "2500" << a << e << endl;                               if ((count == 2500) && getBet() != getSpinA()|| getSpinE())            //lose                               {                                   cout << (left) << setw (15) << "2500" << a << e << endl;                                   if ((count == 25000) && getBet() == getSpinA()|| getSpinE())            //win                                   {                                       a = total + 36.00;                                       e = total + 36.00;                                       cout << (left) << setw (15) << "25000" << a << e << endl;                                       if ((count == 25000) && getBet() != getSpinA()|| getSpinE())        //lose                                       {                                           cout << (left) << setw (15) << "25000" << a << e << endl;                                           if ((count == 250000) && getBet() == getSpinA()|| getSpinE())            //win                                           {                                               a = total + 36.00;                                               e = total + 36.00;                                               cout << (left) << setw (15) << "250000" << a << e << endl;                                               if ((count == 250000) && getBet() != getSpinA()|| getSpinE())        //lose                                               {                                                   cout << (left) << setw (15) << "250000" << a << e << endl;                                               }                                           }return 0;                                       }                                   }                               }                           }                       }                   }               }           }       }   } }```
• 10-27-2003
Hammer
Re: Help with roulette program
>>it shows the same thing twice
That's to do with your logic. I strongly recommend you review all those imbedded "if" statements.

>>and in the american column it shows 130130 and nothing in the european column.
Well, look at your code, when you output a and e, is there any white space between them? If there isn't, what do you think the output will look like? (hint: setw() is only remember for the next output)
Code:

`cout << (left) << setw (15) << "25" << a <<e << endl;`
• 10-27-2003
joshdick
Code:

```(a != b || c) // is not the same as (a != b || a != c)```
Don't use global variables. Use more descriptive identifiers. Seed your random number generator only once at the beginning of main() using the current time.