My bomb defusal tripleX game w/ if else statements

#include <iostream>


int main()
{
    //This is the text setup for the game
    std::cout << "The bomb defuser turns to you and yells,";
    std::cout << std::endl;
    std::cout << "\"We need to cut the correct wires to stop the bomb!\"" << std::endl;

    //Declare the 3 number code
    const int WireA = 2;
    const int WireB = 3;
    const int WireC = 4;

    const int WireSum = WireA + WireB + WireC;
    const int WireProduct = WireA * WireB * WireC;

    /*
    This is a multiline comment
    boop
    */

    //Print WireSum and WireProduct to terminal
    std::cout << std::endl;
    std::cout << "There are 3 numbered wires to cut." << std::endl;
    std::cout << "The sum of the numbers is " << WireSum << "." << std::endl;
    std::cout << "The numbers mulitplied together equal " << WireProduct << "." << std::endl;
    std::cout << "What number wire should they cut? ";

    //initialise the player's guess
    int PlayerGuessA, PlayerGuessB, PlayerGuessC;

    //Input & display the player's guess
    std::cin >> PlayerGuessA;
    std::cin >> PlayerGuessB;
    std::cin >> PlayerGuessC;
    std::cout << "\"Cut the #" << PlayerGuessA << " " << PlayerGuessB << " " << PlayerGuessC;
    std::cout << " wire!\" You yell.";
    
    //Declare the sum & product
    int GuessSum = PlayerGuessA + PlayerGuessB + PlayerGuessC;
    int GuessProduct = PlayerGuessA * PlayerGuessB * PlayerGuessC;

    //Win & lose conditions
    if (GuessSum == WireSum && GuessProduct == WireProduct)
    {
        std::cout << "You Win!";
    }
    else
    {
        std::cout << "You've snipped the wrong wire, better start running!";
    }
    return 0;
}
1 Like

:+1:

Privacy & Terms