/* * This program makes you say "cheese curls" three times. * Its a peice of software nearly as important as Microsoft Windows. */ #include #include int main() { std::cout << "You must say cheese curls on the next three lines" << std::endl; // Repeated ask the user to say cheese until s/he does. int count = 0; while(count < 3 && std::cin.good()) { // Instruct the user. std::cout << "Attempt " << count+1 << ": Please say \"cheese curls\": "; // Read the first word. std::string cheese; std::cin >> cheese; if(cheese != "cheese") { // Complain, discard the rest of the line, and start // the line over. std::cout << "NO!!! You start with \"cheese\"! " << "Please follow instructions." << std::endl; std::cin.ignore(1024, '\n'); continue; } // Now we need to find curls. std::string curls; std::cin >> curls; if(curls != "curls") { // Complain, discard the rest of the line, and start // the line over. std::cout << "Oh, c'mon! You are supposed to say " << "\"curls\" now. You will just have to " << "start the line over." << std::endl; std::cin.ignore(1024, '\n'); continue; } // Count this successful line ++count; } // Final message of approval or complaint if(std::cin.good()) { std::cout << "Thank you for saying \"cheese curls\" three " <<"times. " << std::endl; } else { std::cout << "YOU! You closed the console instead of " << "typing your lines!" << std::endl <<"We'll get you next time." << std::endl; } }