#include <iostream>
int main()
{
// Print to terminal the story setup
std::cout << "+ I've known a few guys who thought they were pretty smart";
std::cout << std::endl;
std::cout << "+ But you've got being right down to an art";
std::cout << std::endl << std::endl;
std::cout << "+ You think you're a genius, you drive me up the wall";
std::cout << std::endl;
std::cout << "+ Well figure out this 3 number code, you know-it-all! ";
// Declare the three number code as a constant
const int CodeA = 4;
const int CodeB = 3;
const int CodeC = 2;
// Calculations using the code to offer as clue to the user.
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
// Print to terminal the clues.
std::cout << std::endl << std::endl;
std:: cout << "+ Oh-oo-oh, the sum is " << CodeSum << std::endl;
std:: cout << "+ Oh-oo-oh, the product is " << CodeProduct << std::endl;
int GuessA, GuessB, GuessC;
std:: cout << "+ Okay, so type in your answers ... ";
std:: cin >> GuessA;
std:: cin >> GuessB;
std:: cin >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std:: cout << std::endl << "+ That ... does impress me much.";
}
else
{
std:: cout << std::endl << "+ That don't impress me much.";
}
return 0;
}
Here is the code after 2.23. I’ve modified the story to celebrate Canadian singer and songwriter and Queen of Country Pop, Shania Twain.