Help me with my code? please?

For some reason, after I input 'Y' or 'N' its still showing me th error from the if statement. Am i doing something wrong in the toupper function? or is it the if statement? Sorry I am new to C++
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

#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <cctype>
using namespace std;
#define storepercent = 0.8

//Declaring other functions other than main
void storeCalculations(double, double);


int main()
{
	//Holds the user's input
	string ISBN;
	double pricepercopy;
	char requiredorsugg, neworold;
	int classsize;

	//Asks for the User's Input
	cout << "What is the ISBN?" << endl;
	cin >> ISBN;

	cout << "What is the price per copy?" << endl;
	cin >> pricepercopy;

	cout << "What is the class size?" << endl;
	cin >> classsize;


	cout << "Is the book required or suggested? (Y/N):  " << endl;
	cin >> requiredorsugg;
	requiredorsugg = toupper(requiredorsugg);
	if (requiredorsugg != 'Y' || requiredorsugg != 'N')
	{
		cout << "ERROR: Must type Y or N" << endl;
		system("pause");
		exit(100);
	}

	cout << "Is the required or suggested book will be new or old? (N / O):" << endl;
	cin >> neworold;
	neworold = toupper(neworold);
	if (neworold != 'N' || neworold != 'O')
	{
		cout << "ERROR: Must type 'N' or 'O'" << endl;
		system("pause");
		exit(100);
	}


}
Last edited on
if (requiredorsugg != 'Y' || requiredorsugg != 'N')
you need to use && here not or
if (requiredorsugg != 'Y' && requiredorsugg != 'N')
Topic archived. No new replies allowed.