TripleX code so far (Section 2 - Lesson 25)

#include

int main()
{
std::cout << std::endl;
std::cout << “Welcome aboard Captain! We require your help to repair the broken engine!”;
std::cout << std::endl;
std::cout << “To do so, you must find the right sequence and bypass the security system.” << std::endl;

const int CodeA = 4;
const int CodeB = 6;
const int CodeC = 3;

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

std::cout << std::endl;
std::cout << "- The code is composed by 3 numbers." << std::endl;
std::cout << "- The codes add-up to: " << CodeSum << std::endl;
std::cout << "- The codes multiply to give: " << CodeProduct << std::endl;

int GuessA, GuessB, GuessC;;
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 << "Valid code";
}
else
{
    std::cout << "Invalid code";
}

return 0; 

}

1 Like

:clap::clap::clap:

1 Like