In: Computer Science
C++ needed
Create a loop which gives the player instructions on what to input. Then read input from the player. The input will be either one of three options:
• If the user enters the word “answer” or some other string you choose to indicate the player is ready to end the game and guess. In this case, output the hidden rule.
• Three numbers separated by spaces. Let’s call a trio of numbers and the corresponding output a Guess. Once a user makes a Guess. If the user enters a sequence that follows the rules, output “Yes!” Otherwise output “No.”
• Treat any other entry as an exception.
#include<iostream>
using namespace std;
int main()
{
string word;
int a,b,c,option;
while(1)
{
cout<<"1. Enter trio of numbers\n2. Enter word
--answer\nchoose : ";
cin>>option;
if(option==1)
{
cout<<"Enter trio of numbers : ";
cin>>a>>b>>c;
if( a<b && b<c && a<c)
cout<<"yes"<<endl;
else
cout<<"No"<<endl;
}
else
{
cout<<"Enter word : ";
cin>>word;
if(word=="answer")
{
cout<<"Hidden rule applied is INCREASING ORDER";
break;
}
else
cout<<"Invalid word , continue";
}
}//end while loop
return 0;
}