Output repeats itself after user input?

Difficult to describe this question as i'm fairly new to c++, but every time I enter a number after the main function registers the cin input and passes it to the double getSales function, it prompts the user with "Error, sales must be 0 or larger" even though I input a positive number. It'll work perfectly when I input the first number, but when it asks for example the next input Southeast sales quarterly income, if I put a positive it gives me the error message and prompts for valid input, and it'll do the same for the next. Anyone mind describing what i'm doing wrong with my code? Thanks in advanced.

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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 #include <iostream>
using namespace std;

//prototype functions
void findHighest(int, int, int, int);
double getSales(int, int, int, int);

//global variables
int NortheastSales = 0;
int SoutheastSales = 0;
int NorthwestSales = 0;
int SouthwestSales = 0;


int main()
{
    cout<<"Enter Northeast's quarterly sales: ";
    cin>>NortheastSales;
    getSales(NortheastSales,SoutheastSales, NorthwestSales, SouthwestSales);


    cout<<"Enter Southeast's quarterly sales: ";
    cin>>SoutheastSales;
    getSales(NortheastSales, SoutheastSales, NorthwestSales, SouthwestSales);


    cout<<"Enter Northwest's quarterly sales: ";
    cin>>NorthwestSales;
    getSales(NortheastSales, SoutheastSales, NorthwestSales, SouthwestSales);


    cout<<"Enter Southwest's quarterly sales: ";
    cin>>SouthwestSales;
    getSales(NortheastSales, SoutheastSales, NorthwestSales, SouthwestSales);


    findHighest(NortheastSales, SoutheastSales, NorthwestSales, SouthwestSales);

    return 0;

}


//this function validates user input for each division's quarterly income
double getSales(int NortheastSales, int SoutheastSales, int NorthwestSales, int SouthwestSales)
{

    while (NortheastSales < 0)
    {
        cout<<"Error, sales must be 0 or larger"<<endl;
        cout<<"Enter Northeast's quarterly sales: ";
        cin>>NortheastSales;
    }


    while ( SoutheastSales < 0)
    {
        cout<<"Error, sales must be 0 or larger"<<endl;
        cout<<"Enter Southeast's quarterly sales: ";
        cin>>SoutheastSales;
    }


    while (NorthwestSales < 0)
    {
        cout<<"Error, sales must be 0 or larger"<<endl;
        cout<<"Enter Northwest's quarterly sales: ";
        cin>>NorthwestSales;
    }


    while (SouthwestSales < 0)
    {
        cout<<"Error, sales must be 0 or larger"<<endl;
        cout<<"Enter Southwest's quarterly sales: ";
        cin>>SouthwestSales;
    }


}






//this function finds the highest number of each division's quarterly income and displays it in the main function.
void findHighest(int NortheastSales, int SoutheastSales, int NorthwestSales, int SouthwestSales)
{
    if(NortheastSales >SoutheastSales && NortheastSales > NorthwestSales)
    {
        if (NortheastSales > SouthwestSales)
            cout<<"Northeast has the largest sales with $"<<NortheastSales<<endl;
    }

    else if (SoutheastSales > NortheastSales && SoutheastSales > NorthwestSales)
    {
        if (SoutheastSales > SouthwestSales)
            cout<<"Southeast has the largest sales with $"<<SoutheastSales<<endl;
    }

    else if (NorthwestSales > NortheastSales && NorthwestSales > SoutheastSales)
    {
        if (NorthwestSales > SouthwestSales)
            cout<<"Northwest has the largest sales with $"<<NorthwestSales<<endl;
    }

    else (SouthwestSales > NortheastSales && SouthwestSales > SoutheastSales);
    {
        if (SouthwestSales > NorthwestSales)
            cout<<"Southwest has the largest sales with $"<<SouthwestSales<<endl;
    }





}
Also, if I enter all positive numbers the issue doesn't occur. It's only when I enter one negative number that the issue happens.
Topic archived. No new replies allowed.