Reference no: EM131013058
Build a code in C++ that will play the high-lo game.
Hi-Lo Game
This game will ask the user to guess a number between 0 and 10. Suppose the game wants to guess the number 7. The game will keep helping the user to guess the number until the user enters 7. A sample output will look like the following:
What is your name?
Sadia
********************************
Welcome to the Hi-Lo Game, Sadia!
********************************
Guess a number between 0 - 10 :
5
Your guess is too low. Guess again!
8
Your guess is too high. Guess again!
6
Your guess is too low. Guess again!
7
That is correct, you win!
Would you like to give the game another try? (Yes or No)
Yes
Guess a number between 0 - 10:
Your guess is too low. Guess again!
That is correct, you win!
#include <iostream>
#include <iomanip>
using namespace std;
char chr;
int main()
{
int number;
int guess;
int tries;
char answer;
char name;
cout<<"What is your name?n";
cin>>name;
cout<<"********************************n";
cout<<"Welcome to the Hi-Lo Game,"<<name<<"!"<<endl;
cout<<"********************************"<<endl;
srand(number>0);
do
{
number=rand()%10+1; break;
cout<<"Enter a number between 0 and 10"<<endl;
cin>>guess;
if (number>guess)
cout<<"Your guess is too low. Guess again!n";
tries++;
} while (number<guess);
cout<<"Your guess is too high. Guess again!n";
tries=1;
if (number==guess)
cout<<"That is correct, you win!n";
do
{
cout<<"Would you like to give the game another try? (Yes or No)n";
cin>>answer;
} while (answer=='Yes');
cin>>chr;
return 0;
}
Develop a frequency distribution
: An executive's telephone log showed the following data for the length of 30 calls initiated during a day. Develop a frequency distribution
|
What are the 3 different types of opcodes for the lc3
: What are the 3 different types of opcodes for the LC3
|
Determine the maximum distributed load wmax
: The beam is supported by a pin at C and by a short link AB. Each pin has a diameter of 20 mm. Assume L = 1.2 m and θ = 20o. If the average shear stress in the pins at A, B, and C cannot exceed 115 MPa, determine the maximum distributed load wmax th..
|
Motherboard beep codes are useful for troubleshooting
: Motherboard beep codes are useful for troubleshooting hardware and configuration faults. If all is well, a computer should beep once to signal this and continue the boot-up process. If there is no beep, or if nothing happens after the power button is..
|
Build a code that will play the high-lo game
: Build a code in C++ that will play the high-lo game - This game will ask the user to guess a number between 0 and 10.
|
Determine the beginning balance in spartan
: Determine the beginning balance in Spartan's accumulated E&P at the beginning of the next year.
|
Determine the gradient and the value
: Let this be a three-dimensional scalar field - f(x, y, z) = (1)/(x2 + y2 + z2) - z, Determine the gradient grad f and the value of |grad f| in spherical coordinates
|
Sum of the numbers shown uppermost
: A pair of fair dice is rolled. What is the probability of each of the following? (Round your answers to three decimal places.) (a) The sum of the numbers shown uppermost is less than 4
|
Determine the reaction forces at e and d
: The booms BE and CD are also pinned to the cross-link BC using smooth pins at B and C. The length of boom BE = CD = 6.5 m. The weight of BE, CD and BC are very small and can be ignored in the analysis. Determine the reaction forces at E and D.
|