#include #include using namespace std; int Factorial(int n); bool AskUserToContinue(void); string MakeLower(string word); int main() { int i{4}; bool keepGoing{true}; while (keepGoing) { cout << i << "! = " << Factorial(i) << endl; keepGoing = AskUserToContinue(); } return 0; } int Factorial(int n){ int i; int returnValue{1}; for(i=2; i <= n; ++i) { returnValue *= i; } return returnValue; } bool AskUserToContinue(void){ string userInput; bool doContinue; bool goodAnswer{false}; while (not goodAnswer) { cout << "Do you want to compute another factorial? (yes,no) "; cin >>userInput; userInput = MakeLower(userInput); if (userInput == "yes") { doContinue = true; goodAnswer = true; }else if (userInput == "no") { doContinue = false; goodAnswer = true; } else { cout << "Please enter yes or no " << endl; } } return doContinue; } string MakeLower(string word){ int i; for(i = 0; i < word.size(); ++i) { word[i] = tolower(word[i]); } return word; }