Strings and loops in c++

Hello, new programmer here.

I'm asking the user for a weekday and then uppercasing it. Then checking (with a while loop) to see if what they typed is actually a weekday. No matter what I type, an actual weekday or not, my code's telling me that they've not entered a weekday.

1
2
3
4
5
6
7
8
9
10
11
12
13
14


string weekDay;

cout << "Enter the first day of the year" << endl;

cin >> weekDay;

// uppercasing the string
transform(weekDay.begin(), weekDay.end(), weekDay.begin(), ::toupper);

cout << weekDay << endl;

while (weekDay != "SUNDAY" || weekDay != "MONDAY" || weekDay != "TUESDAY" || weekDay != "WEDNESDAY" || weekDay != "THURSDAY" || weekDay != "FRIDAY" || weekDay != "SATURDAY")
Last edited on
Use AND (&&), not OR (||) throughout line 14.

In future, show runnable code.
Thank you! Will do.
Topic archived. No new replies allowed.