//fork in the road //explaining the notions of if, then, else statements //Yoram Chisik 2005 #include #include int main() { std::string direction; std::cout << "You have come to a fork in the road,\nenter the direction you want to follow:"; std::cin >> direction; if (direction == "left") { std::cout << "You have decided to turn left\n"; } else if (direction == "right") { std::cout << "You have decided to turn right\n"; } else if (direction == "ahead") { std::cout << "You have decided to move straight ahead\n"; } else if (direction == "back") { std::cout << "You have decided to turn back\n"; std::cout << "How are you turning back [reverse, uturn]:"; std::cin >> direction; if(direction == "reverse") { std::cout << "You have decided to reverse\n"; } else if (direction == "uturn") { std::cout << "You have decided to do a uturn\n"; } else { std::cout << direction << " does not compute \n"; } } else { std::cout << "You have made an impossible choice and will therefore vanish into the void\n"; } system("PAUSE"); return 0; }