TripleX Game so far - IF/ELSE STATEMENT

#include

int main()

{

//Print Welcome statement

std::cout << "You are in the process of robbing the biggest bank in the world!...\n";

std::cout << "You have reached the vault where the Gold is and need to enter the correct codes to continue... \n";

// Declare codes

const int CodeA = 0;

const int CodeB = 0;

const int CodeC = 0;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;

//Print CodeSum and CodeProduct of codes to the terminal

std::cout << std::endl;

std::cout << "+ There are 3 number in the code\n";

std::cout << "+ The codes add up to: " << CodeSum << "\n";

std::cout << "+ The codes multipy to give: "<< CodeProduct << "\n";

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 << "Success, you're in better hurry!!!";

}

else

{

    std::cout << "Wrong Codes, you've set off the alarms. Good luck";

}

return 0;

}

1 Like

Are you comfortable with IF and ELSE statements?

Privacy & Terms