My work so far - escaping the building

#include <iostream>

int main()

{   

    //Print welcome messages to the terminal

    std::cout << "You have to get out of this building!  You'll need to find the codes on each floor to operate the elevator." << std::endl;

    std::cout << "Get to the chopper on the roof to escape!" << std::endl;

    // Declare 3 number code

    const int CodeA = 4; 

    const int CodeB = 3;

    const int CodeC = 5;

    const int CodeSum = CodeA + CodeB + CodeC;

    const int CodeProduct = CodeA * CodeB * CodeC;

    

    //Print CodeSum and CodeProduct to the terminal

    std::cout << std::endl;

    std::cout << "+ There are 3 numbers in the code" <<std::endl;

    std::cout << "+ The numbers in the code add up to: " << CodeSum << std::endl;

    std::cout << "+ The numbers in the code multiply to give: " << CodeProduct << std::endl;

    int GuessA, GuessB, GuessC;

    std::cout << "Please enter the code here.  Use a space between each number of the code: ";

    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 << "Congratulations!  You made it to the roof!  You successfully escape in the helicopter.";

    }

    else

    {

        std::cout << "Failure!  You entered the wrong code!  The building goes into lockdown and you are captured.";

    }

    return 0;

}
1 Like

Nice job so far.

Privacy & Terms