以下では、ユーザーの入力を Y または y または N または n のみに制限しようとしています。問題が何であるかを指摘できるように、コードに関する私のコメントに従ってください。私はこのフォーラムに非常に慣れていません。プログラミングに情熱を持っています。誰か助けてください。ありがとうございました。while ループ (do-while ループではない) は、私が問題を抱えている部分です。!= を正しく使用していない可能性があります。まだ何も進んでいませんが、今通っているクラスは入門レベルです。
cout << "Would you like to use this program again?: ",
cin >> ans;
if(ans =='Y'||ans =='y'||ans =='N'||ans =='n')
break;
else //This is where I'm having problem with.
while (ans != 'Y'||ans != 'y'||ans !='N'||ans !='n')
{
cout << "Please enter Y or y if you like to use the program again and N or n do exit.",
cin >> ans; //If the question is asked and no matter what I input for ans, the while loop never gets exited. Why? Is there something I didn't use right?
}
}while (ans == 'Y'||ans =='y');
return 0;