#include #include using namespace std; string yesOrNo(string word) // precondition: // postcondition: { string first; if (word.length() == 0) { return "Error"; } first = word.substr(0,1); if (first == "y" || first == "Y") { return "Yes"; } if (first == "n" || first == "N") { return "No"; } return "WishyWashy"; } int main() { string response; cout << "enter a word in response to a yes/no question: " ; cin >> response; cout << yesOrNo(response) << endl; return 0; } /* Sample output: prompt> yesOrNo enter a word in response to a yes/no question: yo Yes prompt> yesOrNo enter a word in response to a yes/no question: huh WishyWashy prompt> yesOrNo enter a word in response to a yes/no question: sure WishyWashy prompt> yesOrNo enter a word in response to a yes/no question: negative No prompt> yesOrNo enter a word in response to a yes/no question: YES Yes */