Triplex code void PrintIntroduction

#include

void PrintIntroduction()
{
// Strings describing the main purpouse of the game.
std::cout << “Welcome aboard Captain! We require your help to repair the broken engine!\n”;
std::cout << “To do so, you must find the right sequence and bypass the security system.\n\n”;
}

void PlayGame()
{
PrintIntroduction();

//Inizialization (declaration) of our integers.
const int CodeA = 4;
const int CodeB = 6;
const int CodeC = 3;

const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;

// Sum and product gave as output of our first part of the game.
std::cout << "- The code is composed by 3 numbers.";
std::cout << "\n- The codes add-up to: " << CodeSum;
std::cout << "\n- The codes multiply to give: " << CodeProduct;
std::cout << std::endl;

// Player guesses
int GuessA, GuessB, GuessC;;
std::cin >> GuessA >> GuessB >> GuessC;

int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;

// Check if the player's input is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
    std::cout << "\nValid code";
}
else
{
    std::cout << "\nInvalid code";
}

}

int main()
{
PlayGame();
return 0;
}

Interesting how some of your code is in t correct format and the rest isn’t. Was that intentional?

To be honest it was completely unintentional. I tried twice to copy my code in the topic and try to made it in right format but everytime that was the result so in the end I gave up.

Privacy & Terms