#include <iostream>
int main()
{
// Beginning storyline, prompting user for codes
std::cout << "You are a secret agent breaking into a secure server room.";
std::cout << std::endl;
std::cout << "You need to enter the correct codes to continue ... " << std::endl;
// Declaring three number code
const int a = 4;
const int b = 7;
const int c = 8;
// Print sum and product to the terminal
std::cout << "The sum of the variables is: " << a + b + c << std::endl;
std::cout << "The product of the variables is: " << a * b * c << std::endl;
return 0;
}
#include <iostream>
int main()
{
std::cout << "Welcome To TripleX";
std::cout << std::endl;
std::cout << "You are a detective breaking into the secret sever rooms of a notorious cyberthief";
std::cout << std::endl;
std::cout << "You need to enter the correct password to continue...";
int a = 4;
std::cout << a;
return 0;
}
The variable was not printed. What is the reason for this error?
#include <iostream>
void PrintIntroduction(int Difficulty)
{
/* std short for standard = Namespace
- :: is a Scope Operator telling the compiler to chek for code inside the Namespace
- Next comes what is being called from the name space
- << this outputs what is to the right
- "" text within will be printed to comand
- std::endl tells the program to start a new line
*/
std::cout << "\n\nI have trapped you in testing chamber " << Difficulty;
std::cout << "\nI wil set you free once you have compleated all the codes\n";
std::cout << "If you fail, be prepared for the consequences ... \n\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
/*const stops you from being able to change the info
- int is any whole number
- Next the name is stated and what info is carried with the name*/
const int CodeA = 4;
const int CodeB = 7;
const int CodeC = 3;
//For maths +-/* Plus,Minus,Divide,Tmes
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeMulti = CodeA * CodeB * CodeC;
//You can add << std::endl to the end of a line of script
std::cout << "* There are 3 numbers in the code";
std::cout << "\n* The numbers add-up to: " << CodeSum;
std::cout << "\n* The numbers also multiply to: " << CodeMulti << std::endl;
//Player Guess Input
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessMulti = GuessA * GuessB * GuessC;
//Check if player won or lost
if (GuessSum == CodeSum && GuessMulti == CodeMulti)
{
std::cout << "\nYou guessed corectly, let's see if your luck continues\n\n";
return true;
}
else
{
std::cout << "\nYou Failed\n\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
int const MaxLevel = 10;
while (LevelDifficulty <= MaxLevel) // Loop the game till all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear();
std::cin.ignore();
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "Congratulations, you may leave";
//return will end your script
return 0;
}
/* When changeing code right click and "change all occurrences"
* std::cout << "he said: \"Hello, World!\""; <--- The \ allow the "" to be printed
* std::cout << "Hello, World!\n"; <--- The \n inserts a new line
*/
// Print the Welcome message
std::cout <<"\n\nYou are a secret agent trying to enter a Level " << Difficulty;
std::cout <<" server room....\nEnter the correct code to continue...\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
// Declare 3 number code
const int CodeA= 2;
const int CodeB = 4;
const int CodeC = 6;
//Print sum and product to the terminal
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
std::cout << "* There are 3 numbers in the code\n";
std::cout << "* The sum of all three codes: "<< CodeSum;
std::cout << "\n* The product of codes is: "<< CodeProduct << std::endl;
// Store Player Guess
int GuessA, GuessB, GuessC;
//Ask for players guess
std::cin >> GuessA >> GuessB >> GuessC;
int GuessProduct = GuessA*GuessB*GuessC;
int GuessSum = GuessA + GuessB + GuessC;
// Check if the players answer is correct or not
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\nBravo Agent, You got it, Access Granted!";
return true;
}
else
{
std::cout << "\nAccess Denied...Incorrect Code, TRY AGAIN..!";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
int const MaxLevel = 5;
while (LevelDifficulty <= MaxLevel)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "\nYou are Master, Congratulations You Successfully Got the Access to FINAL SERVER
ROOM!!";
return 0;
Before of the explanation of “less than or equal to” i’ve come up with a different version to solve the problem, obviously yours is cheaper in therms of time, but atleast i’ve tryed ^_^"
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;
while (true) //Loop game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); //Discard the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
if (LevelDifficulty==MaxDifficulty)
{
return 0;
}
}
return 0;
//Print welcome message to the terminal
cout<<"\n\nYou are a secret agent breaking into a Level "<<Difficulty<<" secured server room..."<<endl;
cout<<"Enter the correct code to continue"<<endl;
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
//Declaring 3 number code
const int CodeA = 4;
const int CodeB = 3;
const int CodeC = 2;
cout<<" + There are three codes"<<endl<<endl;
const int CodeSum = CodeA+CodeB+CodeC;
const int CodeProduct = CodeA*CodeB*CodeC;
//Print the sum and product
cout<<" + The codes add to give: "<<CodeSum<<endl;
cout<<" + The codes multiply to give: "<<CodeProduct<<endl;
//Taking Guess values from the player
int GuessA, GuessB, GuessC;
cin>>GuessA;
cin>>GuessB;
cin>>GuessC;
//Evaluating the values entered by the player
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Printing the Sum and Product
cout<<"The sum of the entered values is: "<<GuessSum<<endl;
cout<<"The product of the entered values is: "<<GuessProduct<<endl;
//Checking
if (CodeSum==GuessSum && CodeProduct==GuessProduct)
{
cout<<"You win!\n";
return true;
}
else
{
cout<<"You lost! Better luck next time.\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 5;
while (LevelDifficulty<=MaxDifficulty)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
cin.clear(); //clears the error
cin.ignore(); //ignores the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
cout<<"\n\n Malware updated successfully. \n Now run away from here\n";
return 0;
my code so far, i love the course and i have a lot of fun while coding,
The story is an among us related story.
#include <iostream>
void PrintIntroduction(int Difficulty)
{
//Print welcome messages to the ternimal
std::cout << "\n\nYou are at elecrical, lost and scared but you need to do the task\n";
std::cout << "for every task you do right you will eject an impostor, but every time you fail you will eject a fellow crewmate\n";
std::cout << "you are curently in level: " << Difficulty;
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
//Declare 3 number code
const int CodeA = rand();
const int CodeB = rand();
const int CodeC = rand();
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
//Print sum and product to the ternimal
std::cout << "\n\n-Every task you do will need to have 3 digits of code";
std::cout << "\n-The code adds up to: " << CodeSum;
std::cout << "\n-The code multiply to give: " << CodeProduct;
std::cout << std::endl;
//Store player guess input
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if the player is correct
if(GuessSum == CodeSum && GuessProduct == CodeProduct)
{
//win
std::cout << "\n\nyeah, that is what i call a win\n";
std::cout << "a SUSSY IMPOSTOR just got thrown out\n";
std::cout << "you are as good as i thought, keep up the nice work\n";
return true;
}
else
{
//lose
std::cout << "\n\nreally, i thought you were better than this\n";
std::cout << "a fellow crewmate has just been thrown in the deep vacuum of space...\n";
return false;
}
}
int main()
{
int LevelDificulty = 1;
const int MaxLevel = 10;
while (LevelDificulty <= MaxLevel) // Loop the game until all the levels are completed
{
bool bLevelComplete = PlayGame(LevelDificulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDificulty;
}
}
std::cout << "\n***congratulations you are the best crewmate in the world :)***\n";
return 0;
}
I wanted to continue this course lately and this is what I’ve done so far
#include <iostream>
void PrintIntroduction(int Difficulty)
{
// Introduces the game to the player
std::cout << "\n\nYou are a secret agent breaking into a level " << Difficulty;
std::cout << " secure server room. \nYou need to enter the correct codes to continue...\n\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
// Declare 3 numbers 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 the terminal
std::cout << std::endl;
std::cout << "+ There are 3 numbers in the code";
std::cout << "\n+ The codes add-up to: " << CodeSum;
std::cout << "\n+ The codes multiplies by: " << CodeProduct << std::endl;
// Store the player guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
// Check if the player's guess is correct
if (GuessSum == CodeSum && GuessProduct == CodeProduct)
{
std::cout << "\n*** You win ! Up to the next level ! ***\n";
return true;
}
else
{
std::cout << "\n*** You lose... Let's retry ! ***\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
int const MaxLevel = 5;
while (LevelDifficulty <= MaxLevel) // Loop game until all levels completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); // Clears any erros
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "You made it ! Congratulations and thank you for playing !";
return 0;
}
// Back Story (Expression Statements)
std:: cout << "\n\n You are trying to get aimbot and hack into a Level " << Difficulty;
std:: cout << " Fortnite server \n Get the numbers correct to get in...\n";
}
bool PlayGame(int Difficulty)
{
PrintIntroduction(Difficulty);
//Declare Code
const int CodeA = 4;
const int CodeB = 2;
const int CodeC = 1;
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProduct = CodeA * CodeB * CodeC;
// Printing Sum and Product
std:: cout << "There are three numbers in the code\n";
std:: cout <<"*When you add these numbers, you get ";
std:: cout << CodeSum <<"*\n";
std:: cout << "*When you multiply these numbers, you get ";
std:: cout << CodeProduct<< "*\n\n";
//Showing User Input
int GuessA, GuessB, GuessC;
std:: cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Showing if User is Right or Wrong
if (GuessSum==CodeSum && GuessProduct == CodeProduct)
{
std:: cout << "Nice Job, On to Level "<< Difficulty << "!";
return true;
}
else
{
std:: cout <<"Oh, that's not quite right. Try again";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
int const MaxDifficulty = 10;
while (LevelDifficulty <= MaxDifficulty)
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear();// Clears all the errors
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout << "Congratulations, You have successfully infiltrated the Servers!";
return 0;
#include <iostream>
using namespace std;
void PrintIntroduction()
{
cout << " _______ _ _______ _ \n"
"(_______)| | ( ______) (_) \n"
" _ | | _ ____ \\ \\ ____ _ ____ ____ \n"
"| | | || \\ / _ ) \\ \\ | _ \\ | | / ___) / _ )\n"
"| |_____ | | | |( (/ / _____) )| | | || || | ( (/ /\n"
" \\______)|_| |_| \\____) (______/ | ||_/ |_||_| \\____)\n"
" |_| \n";
//Create the setting for the puzzle
cout << "You enter The Spire and find a door on the other end. \n";
cout << "You must enter the correct numbers to move through the next door... \n";
}
void PrintLevel(int Difficulty)
{
cout << "\nRoom "<< Difficulty << endl;
}
bool PlayGame(int Difficulty, int MaxDifficulty)
{
//Declare 3 number code
const int CodeA = rand();
const int CodeB = rand();
const int CodeC = rand();
//Calculate the sum and product
const int CodeSum = CodeA + CodeB + CodeC;
const int CodeProd = CodeA * CodeB * CodeC;
//Print sum and product to terminal
cout << endl;
cout << "+ There are 3 numbers in the code \n";
cout << "+ The sum of the numbers is: " << CodeSum << endl;
cout << "+ The product of the numbers is: " << CodeProd << endl;
int GuessA, GuessB, GuessC;
cout << "\n Enter your guess:\n";
// Store player guess
cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProd = GuessA * GuessB * GuessC;
// Check guess
if (GuessSum == CodeSum && GuessProd == CodeProd)
{
if (Difficulty < MaxDifficulty)
{
cout << "\nThe floor rumbles beneath you.\nThe door slides open...\n";
}
else
{
cout << "\nCongratulations, you have made it through " << MaxDifficulty << " rooms of The Spire."
"\nYou return to the spaceship to take a rest.\n";
}
return true;
}
else
{
cout << "\nTitanium blades shoot out across the room dicing you to pieces.\nDr. Trintigant puts you back together.\n"
"Try Again.\n";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxDifficulty = 2;
PrintIntroduction();
bool bLevelComplete = true;
while (LevelDifficulty <= MaxDifficulty) // Loop game until all levels are completed
{
PrintLevel(LevelDifficulty);
bLevelComplete = PlayGame(LevelDifficulty, MaxDifficulty);
cin.clear(); // Clears any errors
cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
return 0;
}
_______ _ _______ _
(_______)| | ( ______) (_)
_ | | _ ____ \ \ ____ _ ____ ____
| | | || \ / _ ) \ \ | _ \ | | / ___) / _ )| |_____ | | | |( (/ / _____) )| | | || || | ( (/ /
\______)|_| |_| \____) (______/ | ||_/ |_||_| \____) |_|
You enter The Spire and find a door on the other end.
You must enter the correct numbers to move through the next door...
Room 1
+ There are 3 numbers in the code
+ The sum of the numbers is: 12
+ The product of the numbers is: 48
Enter your guess:
2 4 6
The floor rumbles beneath you.
The door slides open...
Room 2
+ There are 3 numbers in the code
+ The sum of the numbers is: 12
+ The product of the numbers is: 48
Enter your guess:
2 4 6
Congratulations, you have made it through 2 rooms of The Spire.
You return to the spaceship to take a rest.
Here is what my Take on Triple X looks like so far:
#include
void PrintIntroduction(int Difficulty)
{
std::cout << "\n\n A master rogue, you are in the midst of the most difficult heist of your career thus far- cracking the level " << Difficulty;
std::cout << "lock on the personal vault safe of the Tyrant Duke Orcanzer...\nEnter the correct combination to continue...\n\n";
}
bool PlayGame(int Difficulty)
{
//Print welcome messages to terminal
PrintIntroduction(Difficulty);
//Declare 3 number code
const int CombinationA = 4;
const int CombinationB = 2;
const int CombinationC = 7;
const int CombinationSum = CombinationA + CombinationB + CombinationC;
const int CombinationProduct = CombinationA * CombinationB * CombinationC;
//Print CombinationSum and CombinationProduct to terminal
std::cout << "\n+ The safe has a 3 number combination";
std::cout << "\n+ The combination numbers add-up to: " << CombinationSum;
std::cout << "\n+ The combination numbers multiply to: " << CombinationProduct << std::endl;
//Store player Guess
int GuessA, GuessB, GuessC;
std::cin >> GuessA >> GuessB >> GuessC;
int GuessSum = GuessA + GuessB + GuessC;
int GuessProduct = GuessA * GuessB * GuessC;
//Check if player's guess is correct
if (GuessSum == CombinationSum && GuessProduct == CombinationProduct)
{
std::cout <<"\n The first lock slips silently open and your fingers move nimbly on to the next.";
return true;
}
else
{
std::cout << "\n You've missed the mark! You check your surroundings and try again.";
return false;
}
}
int main()
{
int LevelDifficulty = 1;
const int MaxLevel = 25;
while (LevelDifficulty <= MaxLevel) //Lop game until all levels are completed
{
bool bLevelComplete = PlayGame(LevelDifficulty);
std::cin.clear(); //Clears any errors
std::cin.ignore(); // Discards the buffer
if (bLevelComplete)
{
++LevelDifficulty;
}
}
std::cout <<"\n\n As the midnight moves softly toward twilight the final lock clicks into place and the door swings open;\n"
"you pocket all contained within, and slip out the window and into the night, a newly crowned Legend.\n\n";
return 0;