So essentially, I am asking the user for a departure time, as well as if it is in the AM or PM. In the code provided, I only test for AM/am (caps or lowercase), but in my actual program I will be testing for both AM/am and PM/pm. Now, when I set my do/while loop up like this:
do {
cout << "Please Enter a Valid Period: ";
cin >> departure_amOrPM;
} while (departure_amOrPM != "AM");
it works just fine, and it lets the program continue when "AM" is entered in all caps. But when I add another test to my loop like this:
do {
cout << "Please Enter a Valid Period: ";
cin >> departure_amOrPM;
} while (departure_amOrPM != "AM" || departure_amOrPM != "am");
it does not work. I tried entering both "AM" and "am", yet it did not let me continue. I don't know how to overcome this obstacle, so any help or tips would be much appreciated. Thanks!
aMis entered? Is that valid?AMor the string isn'tam. Only one of those condition needs to be true, that's what||means. Therefore, for the loop to fail both conditions must fail, and the string must beAM, and the string must also beam, at the same time. Until such time as quantum computing becomes reality, this is just not possible, sorry...