Question

In: Computer Science

C++ needed Create a loop which gives the player instructions on what to input. Then read...

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.

Solutions

Expert Solution

#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;
}


Related Solutions

Using C++, create a program that will input the 3 game scores of a player and...
Using C++, create a program that will input the 3 game scores of a player and then output the level of the player with a message.   Specifications Prompt the user to input 3 game scores (double values). Compute the weighted average (DO NOT JUST ADD AND DIVIDE BY 3!) score as follows: 20% for first game, 30% for second game, 50% for last game Earlier games are worth less in the weighted average; later games are worth more. Print...
In visual Studio C++ Create a program that uses a for loop to input the high...
In visual Studio C++ Create a program that uses a for loop to input the high temperature, and low temperature for each day of the week. The high and low will be placed into two elements of the array. For each loop the high and low will be placed into the next set of elements of the array. After the temps for all seven days have been entered into the array, a for loop will be used to pull out...
****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT...
****NEED CODED IN C++, READ THE INSTRUCTIONS CAREFULLY AND PAY ATTENTION TO THE INPUT FILE, IT IS REQUIRED FOR USE IN THE PROBLEM**** You are to generate a list of customers to serve based on the customer’s priority, i.e. create a priority queue/list for a local company. The company has been receiving request and the request are recorded in a file, in the order the request was made. The company processes each user based on their priority, the highest priority...
Instructions: Create an empty dictionary: zip_dict = {} Loop through all the zip_codes in df_zip Create...
Instructions: Create an empty dictionary: zip_dict = {} Loop through all the zip_codes in df_zip Create a dictionary key for the first 3 digits of a zip_code in zip_dict Continually add population counts to the key that contains the same first 3 digits of the zip code To extract the population you will find this code useful: population = list(df_zip.loc[df_zip['zip'] == zip_code]['population']) To extract the first 3 digits of a zip_code you will find this code useful: int(str(zip_code)[:3])
C++ Create the code Read  numbers from stdin and print their sum to stdout. Input Format One...
C++ Create the code Read  numbers from stdin and print their sum to stdout. Input Format One line that contains  space-separated integers:a , b, c and . Constraints 1≤ a,b,c ≤1000 Output Format Print the sum of the three numbers on a single line. Sample Input 1 2 7 Sample Output 10 Explanation The sum of the three numbers is 1+2+7=10
Needed in C++ In this assignment, you are asked to create a class called Account, which...
Needed in C++ In this assignment, you are asked to create a class called Account, which models a bank account. The requirement of the account class is as follows (1) It contains two data members: accountNumber and balance, which maintains the current account name and balance, respectively. (1) It contains three functions: functions credit() and debit(), which adds or subtracts the given amount from the balance, respectively. The debit() function shall print ”amount withdrawn exceeds the current balance!” if the...
Hello, I Have create this code and Tried to add do while loop but it gives...
Hello, I Have create this code and Tried to add do while loop but it gives me the error in string answar; and the areas where I blod So cloud you please help me to do ( do while ) in this code. // Program objective: requires user to input the data, program runs through the data,calcualtes the quantity, chacks prices for each iteam intered,calautes the prices seperatly for each item, and calculates the amount due without tax, and then...
Create program which verifies if input string is a valid variable declaration or not. Use C...
Create program which verifies if input string is a valid variable declaration or not. Use C programming language. - This program can only use the following variable types: char, float, and int - Remove any newline \n from input string - The input prompt should say ">>> " - If input declaration is valid, it should print "Valid dec\n" - If input declaration is invalid, it should print "Invalid dec\n" - Make sure the identifier entered matches the rules of...
Use C++ language Create a program which will ask the user to input three songs for...
Use C++ language Create a program which will ask the user to input three songs for a playlist (you may use TV shows or movies, if you prefer). Declare three strings to store each of the songs. Use getline to receive the input. Display output which lists each of the songs (or movies or tv shows), on separate lines, with a title on the first line: My Playlist. Insert three lines of comments at the beginning of the program for...
Write a C++ program that prompts the user (or “Player 1”) to input an integer value...
Write a C++ program that prompts the user (or “Player 1”) to input an integer value between 1 and 3 (where 1=paper, 2=scissor, and 3=rock). This input should be passed into a string function called player_RPS(), and returns a string value indicating the selection of paper, scissors, or rock (as mentioned above). Next, the returned string value, along with a generated input from the computer, should be passed into a void function called RPS_comparison(), and determines whether the user’s input...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT