Roulette Program Help

When I run the program at this point i am getting some issues. If I put in 1 or 2 for color it doesn't skip to the else and do the spin procedure. Also if I input a number outside of 1-3 it puts me in the loop and when it exits it doesn't continue. There must be a better way to do all of this. Any help would be appreciated.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <iostream>

using namespace std;

int main()
{
    cout << "Time to play roulette, You start with $100" << endl;
    int color;
    int odd;
    int number;
    int money = 100;
    int bet;
    cout << "Place your Bet\n";
    cin >> bet;
    if (bet>money){
    while (bet>money){
        cout << "You do not have " << bet;
        cin >> bet;
        if (bet<=money){
            continue;
        }
    }
    }
    else {
        cout << "Pick a Color\n1: Red\n2: Black\n3:Skip\n";
        cin >> color;
    if (color > 3 or color < 1){
        while (color > 3 or color < 1){
            cout <<"that is not a valid choice, Choose again\n";
            cin >> color;
        }
    }
    else {
        if (color = 3){
            cout << "1: Odd\n2: Even\n3:Skip\n";
            cin >> odd;
            if (odd > 3 or odd <1){
                while (odd > 3 or odd <1){
                    cout <<"that is not a valid choice, Choose again\n";
                    cin >> odd;
                    if (odd >= 1 and odd <=3){
                        continue;
                    }
                }
            }
            else{
                if (odd = 3){
                    cout << "Pick a number 1-36\n";
                    cin >> number;
                    if (number >36 or number <1){
                        while (number >36 or number <1){
                            cout << "that is not a valid choice, Choose again\n";
                            cin >> number;
                            if (number >= 1 and number <= 36){
                                continue;
                            }
                        }
                        }
                        else{
                        //Spin Protocall
                        }
                }
                else {
                //Spin Protocall
                }
                }
            }
        else {
        //Spin Protocall
        }
        }
    }
    }

if (color > 3 or color < 1)
Remove this 'if' and the accompanying 'else'. The condition in 'while' is sufficient. When this condition is true, the else part will be always skipped, and that is causing the bug.

if (color = 3){
color ==3

if (odd = 3){
odd == 3


Something else you could do to optimize your code is on line 19 you dont need the :
1
2
3
if (bet<=money){
continue;
}

Because in anyways, its gonna go back up to the top since its a while loop.
Topic archived. No new replies allowed.