My source for TripleX after learning if/else statements

I know we haven’t started on the difficulty portion yet, but i went ahead and declared and initialized them anyway aha.

#include<iostream>

int main() 
{ 
    std::cout << "Find and enter the correct codes to bypass the firewall." << std::endl;

    int difficulty = 1; //Difficulty level
    const int maxDifficulty = 10; //Highest difficulty level

    const int CodeA = 20; 
    const int CodeB = 5; 
    const int CodeC = 10;

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


    std::cout << "Security level: " << difficulty << std::endl;
    std::cout << "There's 3 numbers in the code." << std::endl;
    std::cout << "The codes add up to: " << CodeSum << std::endl;
    std::cout << "The codes mutltiply by: " << CodeProduct << std::endl;

    int GuessA, GuessB, GuessC;
    std::cout << "First Code: ";
    std::cin >> GuessA;
    std::cout << "Second Code: ";
    std::cin >> GuessB;
    std::cout << "Third Code: ";
    std::cin >> GuessC;
   
    int GuessSum = GuessA + GuessB + GuessC;
    int GuessProduct = GuessA * GuessB * GuessC;

    if(GuessSum == CodeSum && GuessProduct == CodeProduct)
    {
        std::cout << "Congrats!";
    }
    if(GuessSum != CodeSum && GuessProduct != CodeProduct)
    {
        std::cout << "Hold this L";
    }
    return 0; 
}
2 Likes

We love it when students go above and beyond! Keep it up! :+1:

2 Likes

how to share code like him pls tell

Before pasting your code, press on this icon and it will automatically format it for you when you click post!

1 Like

you are a relly helpfull guy in this community thanx for the adive i will regard it and consider following your advide truly

1 Like

Privacy & Terms