If/Else Statement Troubles

I am attempting to program a console app which simulates opening up a case in CS:GO. First the program generates a random number 1-100 and then depending on that number displays a certain skin that the play is given. However, after struggling to figure out a way to make an if statement that accepts multiples values I am struggling on the else part for accepting other values.

I am currently experiencing issues at line 72 where I am getting the error, "expected '}' before 'else' and 'gWeaponGen' was not declared in this scope.

I am new to programming and started just a few days ago so I am at a loss for the reasoning behind this issue so I would appreciate any help. Also because I am a beginner I expect the code to be very sloppy and inefficient, I ask you kindly to help with me with my main problem before recommending other potential tweaks. Once again I appreciate any assistance I can get.

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
76
77
78
79
80
81
82
83
84
#include <iostream>
#include <conio.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <windows.h>
#include <cstdlib>
#include <ctime>
#include <dos.h>
using namespace std;

int randomizer()
{
    int xRan;
	srand( time(0));

	xRan=rand()%100+1;
	cout << "Shows a random number between 1-15: " << xRan;

	return 0;
}

int main()
{
    int tempest;
    int bLimba;
    int bPile;
    int wSpray;
    int shattered;
    int demeter;
    int bWater;
    int zirka;
    int graven;
    int overgrowth;
    int eDragon;
    int oFoam;
    int graphite;
    int gKoi;
    int fSerpent;
    char name[50];
    int YN;
    int y = 1;
    int n = 0;
    int mSpent = 0;
    int mEarned = 0;

    std::cout << "Welcome to TheM80's Case Opening Simulator!";
    std::cout << "\nWhat's your name? ";
    cin.getline(name, 50);
    system("cls");
    std::cout << "Would you like to open a case, " << name << "?" << endl;
    std::cout << "Enter 1 for yes or 2 for no! ";
    std::cin >> YN;

    if (YN == 1)
    {
        mSpent + 2.49;
        std::cout << "Spinning...";
        Sleep(3500);
        system("cls");

        int gWeapon;
        srand( time(0));
        gWeapon=rand()%100+1;
        int gWeaponGen = gWeapon;
        if(gWeaponGen == 1 || gWeaponGen == 2 || gWeaponGen == 3 || gWeaponGen == 4 || gWeaponGen == 5 || gWeaponGen == 6 || gWeaponGen == 7);
        {
            std::cout << "You're weapon is... ";
            Sleep(1500);
            std::cout << "Nova Tempest!";
        }
        else(gWeaponGen == 8 || gWeaponGen == 9 || gWeaponGen == 10 || gWeaponGen == 11 || gWeaponGen == 12 || gWeaponGen == 13);
        {
            std::cout << "You're weapon is... ";
            Sleep(1500);
            std::cout << "Dual Berettas Black Limba!";
        }
    }

    return 0;
}


The else statement can't have any conditions, perhaps you want to try an else if()?

Also do you realize that there are other comparison operators other than the operator==? And that there are other logical operators other than the OR?

Have you considered using the greater than or less than operators in your if statement?

ie:

if(someValue >0 && someValue < 8)
Last edited on
I didn't even know it was possible to else/if and I'm glad you mention a better way to manage the if statement. I had no idea if it would even work the way I had it.

1
2
3
4
5
        int gWeapon;
        srand( time(0));
        gWeapon=rand()%100+1;
        int gWeaponGen = gWeapon;
        if(gWeaponGen > 0 && < 8)


I tried using this but it returned the error

expected primary-expression before '<' token


What exactly am I missing?
Oops, I should've caught that. I appreciate the help.
Topic archived. No new replies allowed.