#include
int main(){
// Starting Lines to explain the game
StartGame:
std::cout<<"You are a secret agent breaking into a secure server room\n";
std::cout<<"You need to enter the correct codes to continue...\n";
std::cout<<"The three codes that you enter must add up to 8 and their product must be 18\n";
// Declaring variables to get User Input
int GuessA, GuessB, GuessC;
int Sum, Product;
std::cin>>GuessA>>GuessB>>GuessC;
Sum = GuessA + GuessB + GuessC;
Product = GuessA * GuessB * GuessC;
// Game Conditions
if(Sum==8 && Product==18){
std::cout<<"Congrats! You have Won\n";
TryAgain: // Defining a label to allow the user to play the game as many times as he wants - 1
std::cout<<"Do you want to try again?\n";
std::cout<<"Enter Y for yes or N for no\n";
char OptionWin;
std::cin>>OptionWin;
if(OptionWin == 'Y' || OptionWin == 'y')
{
goto StartGame;
}else if(OptionWin == 'N' || OptionWin == 'n')
{
exit(0);
}else{
std::cout<<"There seems to be an error! Please try again\n";
goto TryAgain;
}
}else{
std::cout<<"Snap! You have lost\n";
RestartSelect: // Same as 1
std::cout<<"Do you want to try again?\n";
std::cout<<"Enter Y for yes and N for No\n";
char OptionLose;
std::cin>>OptionLose;
if(OptionLose =='Y' || OptionLose == 'y')
{
goto StartGame;
}else if(OptionLose == 'N' || OptionLose == 'n')
{
exit(0);
}else
{
std::cout<<"There seems to be an error, Please try again\n";
goto RestartSelect;
}
}
return 0;
}