This is a question about my precious homework..
First I call Which function with the parameter "tomato" and with some other parameters..
cout << name << ", do you want to buy some " << vegetable << " (Y/N): ";
cin >> answer1;
(vegetables are tomato and eggplant, so the first question asks if the user wants some tomato)
if (answer1 != 'Y' && answer1 != 'N')
cout << name << ", you have entered an incorrect character." <<endl;
cout << endl;
Now the problem starts..
(1) If the user presses 'Y' then the function calls Price function and wants from user to enter the price of tomato
(2) If the user presses 'N' then the function calls itself again but this time asks user if he/she wants some "eggplant". and again user have two choices (Y/N)
(3) If this time user chooses 'Y' then the function calls Price function and wants from user to enter the price of eggplant
(4)If user chooses 'N' again then the program shows some proper message and finishes.
Now I need to do all this Y/N choices in only one function with if/else statements. I tried to do it but when I say 'N' to the "do you wanna buy some tomato" question, the program asks if the user wants some eggplant. And when I say 'Y', the program uses the situation (1) instead of situation (3).
So how can I make the program use the 3rd situation??