My Code after if/else lesson! Hope you like Parks and Rec! haha

#include

int main()

{

//
// Print welcome messages to terminal and start game.
//

 std::cout << "You are FBI Agent Burt Macklin on a mission to track down and stop the evil spy April Ludgate,\n";

std::cout << "and you need to break into her computer in order to locate her next target. You will need to\n"; 

std::cout << "enter a code in order to unlock her computer.\n\n";

std::cout << "Bewarned the computer might be booby trapped...... so no mistakes!\n";

std::cout << std::endl << std::endl; 

//

// Declare 3 number code.

//

const int CodeA = 4;

const int CodeB = 3;

const int CodeC = 2;

const int CodeSum = CodeA + CodeB + CodeC;

const int CodeProduct = CodeA * CodeB * CodeC;



//

// Print sum and product to terminal

//

std::cout << std::endl;

std::cout << "April is Crazy! There are 3 numbers in the code!" << std::endl;

std::cout << "She left you a note saying the code's numbers add up to: " << CodeSum <<std::endl;

std::cout << "Another message left for you, saying The code's numbers multiply to give: " << CodeProduct << std::endl;

int PlayerGuessA, PlayerGuessB, PlayerGuessC;

std::cout << "Please enter your guess: \n";

std::cin >> PlayerGuessA;

std::cin >> PlayerGuessB;

std::cin >> PlayerGuessC;

std::cout << "You guessed: " << PlayerGuessA << PlayerGuessB << PlayerGuessC << std::endl;

int GuessSum = PlayerGuessA + PlayerGuessB + PlayerGuessC;

int GuessProduct = PlayerGuessA * PlayerGuessB * PlayerGuessC;

if(GuessSum == CodeSum && GuessProduct == CodeProduct)

{

    std::cout << "You did it Burt Macklin! April's computer is unlocked and you were able to locate and save Lil'Sebatian!!!!";

}

else

{

    std::cout << "BOOM!!!!!!!!!\nApril's desk exploded a glitter bomb all over you!\nOh no! They're going to have to clean you up for weeks!";

}

        

return 0;

}

2 Likes

Hahaha :rofl:
I really love this! Great code!

1 Like

#include

int main() // Main portion of code.
{
// Intro
std::cout << " " << std::endl;
std::cout << “Space Shuttle Alpha 203 is about to launch, but Astronaut Bill is in the bathroom.”;
std::cout << std::endl;
std::cout << “You need to enter the correct codes to abort the launch…”;
std::cout << std::endl;
std::cout << " " << std::endl;

//Number Setup
const int CodeA = 3;
const int CodeB = 2;
const int CodeC = 7;

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

//Print out the values
std::cout << "+ There are three numbers in this code." << std::endl;
std::cout << "+ Adding the three numbers together get you: " << CodeSum << std::endl;
std::cout << "+ Multiplying the three numbers together get you: " << CodeProduct << std::endl;
std::cout << std::endl;
std::cout << "Type each number of the code seperated by a space." << std::endl;
std::cout << std::endl;

int GuessA, GuessB, GuessC;
std::cin >> GuessA;
std::cin >> GuessB;
std::cin >> GuessC;
std::cout << std::endl;

int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;

if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
    std::cout << "You entered the correct code!" << std::endl;
    std::cout << std::endl;
}

else
{
    std::cout << "Wrong code, idiot!" << std::endl;
    std::cout << "***Starting Launch Sequence***" << std::endl;
    std::cout << "Shuttle Alpha 203 is launching unmanned." << std::endl;
    std::cout << std::endl;
}


return 0;

}

1 Like

Privacy & Terms