It appears that my while() loop doesn't understand characters ('a') only integers. Even when I tried to store input as a char, the while loop would never exit. To complete this assignment as instructed I need to use letters and numbers in my menu.
So is it true that while loops only understand integers? Also any ideas on how I might solve this dilemma?
#include <iostream>
usingnamespace std;
int main()
{
int input = 0;
//Menu
while (input != 'q' || input != 'Q')
{
cout << "s - report the machine status\n";
cout << "d - drop in a quarter\n";
cout << "1 - pull the 1st knob\n";
cout << "2 - pull the 2nd knob\n";
cout << "3 - pull the 3rd knob\n";
cout << "4 - pull the 4th knob\n";
cout << "r - restock the machine\n";
cout << "q - quit\n";
cin >> input;
switch (input){
case's':
case'S':
//report the machine status
break;
case'd':
case'D':
//drop in a quarter
break;
case 1:
//pull the first knob
break;
case 2:
//pull the second knob
break;
case 3:
//pull the third knob
break;
case 4:
//pull the fourth knob
break;
case'r':
case'R':
//restock the machine
break;
case'q':
case'Q':
//quit
cout << input << "\n";
break;
default:
cout << "I do not understand\n";
}
}
//Outside while loop
return 0;
}