Simple Program Issues Help!

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
#include <iostream>
#include <iomanip>
#include <cctype>
using namespace std;

//****************************************************************************************************

int main()
{
    int  num1,
    num2,
    num3;
    bool ifContinue = true;
    char yesOrNo;
    
    do
    {
        cout << "Enter a number that is between 1 and 50:        ";
        cin >> num1;
        
        while ( (num1 < 2) || (num1 > 49))
        {
            cout << " ** Error - Number is not between 1 and 50 **\n";
            cout << "Enter a number that is between 1 and 50:        ";
            cin >> num1;
        }
        
        cout << "Enter a number that is NOT between 1 and 50:    ";
        cin >> num2;
        
        while ( (num2 > 1) && (num2 < 50))
        {
            cout << " ** Error - Number is between 1 and 50 **\n";
            cout << "Enter a number that is NOT between 1 and 50:    ";
            cin >> num2;
        }
        
        cout << "Enter a number that is greater then 50:         ";
        cin >> num3;
        
        while (num3 <= 50)
        {
            cout << " ** Error - Number less then or equal to 50 **\n";
            cout << "Enter a number that is greater then 50:         ";
            cin >> num3;
        }
        
        cout << "\nYou entered:" << setw(6) << num1 << setw(6) << num2 << setw(6) << num3 << endl
        << endl;
        
//?? the problem area

        cout << "Do you want to enter another set of numbers (Y/N)?\t";
        cin >> yesOrNo;
        
        yesOrNo = (toupper(yesOrNo));
        
        while (yesOrNo != 'Y' || yesOrNo != 'N')
        {
            cout << "** Error - Invalid input! **" << endl
                 << "Do you want to enter another set of numbers (Y/N)?\t";
            cin >> yesOrNo;
            
            yesOrNo = (toupper(yesOrNo));
        }
        
        if ( yesOrNo == 'Y' )
        {
            ifContinue = true;
        }
        else
        {
            ifContinue = false;
        }
        
    }
    while ( ifContinue == true );
    
	return 0;
}


I am having the problem when asking the user if they want enter another set of numbers i always get the "** Error - Invalid input! **" even if a Y or N were entered. could anybody help me get this working it'd be much appreciated.
Your while loop condition is wrong:
while (yesOrNo != 'Y' || yesOrNo != 'N')

If yesOrNo is 'Y', then it still satisfies the second condition (yesOrNo != 'N') and so the loop will be entered.
If yesOrNo is 'N', then it will satisfy the first condition (yesOrNo != 'Y') and so the loop will be entered.

You want && (and) instead of || (or).
wow i feel so dumb thanks for the help!
Topic archived. No new replies allowed.