Hello. I need some help with a program I'm writing. It needs to define a function named menu that returns a char and does not accept parameters. Any help is appreciated.
Currently I have this written in a while loop so that it keeps asking the user to input a char until they input X and then it will stop the loop. I haven't written all the code inside of the case structure thats in the while loop yet just because I didn't want to get to far before I knew if what I'm trying to do would work. What I would like to do is set it up so that the while loop runs only for B, D, Q, and X chars and anything else will break the loop. I'm pretty sure the way I set the while statement here is the problem but I don't know how to fix it. Code so far is
Code:
char menu (){
char 'B';
char 'C';
char 'Q';
char 'X';
char userInput;
cout << "(B)est Price\n(D)iscount\n(Q)uantity\ne(X)it" << endl;
cout << endl;
cout << "Please enter the option (B, D, Q, or X): ";
cin >> userInput;
cout << endl;
//Set while statement to run program while user doesn't enter X
while(userInput != 'X' && (userInput = 'B' || userInput = 'D' || userInput = 'Q')) {
switch(userInput) {
case 'B':
float price1,price2,price3;
cout << "Please enter 3 prices: ";
cin >> price1 >> price2 >> price3;
bestPrice (price1, price2, price3);
}
}
}