char getyorn function

need help...i have to write a function char getyorn - this function asks the user for a 'y' or an 'n' (also uppercase) and rejects any other input with an error message and another request for input. It should return only a lowercase y or a lowercase n. any ideas? please let me know if you need more info..thanks for any help.
What code do you have so far? We will not do HW for you.
cout << "One Armed Bandit!!" << endl;
cout << "What is your name? ";
getline (cin, name);
cout << endl << endl;

cout << "You start off with 200 dollars " << endl;
cout << "Want to play the One Armed Bandit? ";
cin >> //user must enter y or n here and my trouble is with the function that returns a char.
i dont understand that it should only return a lowercase y or n. what if the user types uppercase Y or N?
http://www.parashift.com/c++-faq-lite/input-output.html#faq-15.4 should be helpful for what you are trying to do, as a matter of fact at some point read through all of http://www.parashift.com/c++-faq-lite/.

and it looks like you want to use while and if statements.
Last edited on
Topic archived. No new replies allowed.