Build a code that will play the high-lo game

Assignment Help C/C++ Programming
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;

}

Reference no: EM131013058

Questions Cloud

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.

Reviews

Write a Review

C/C++ Programming Questions & Answers

  Program that asks user to enter the size of the matrix

Write a program that asks user to enter the size of the matrix (rows and column) then, it asks the user to enter the elements of two matrices and finally it adds two matrix and displays the result in C language.

  Implementing a client

The CSE3300 server for this exercise waits to receive messages on UDP port 3300 of tao.ite.uconn.edu (IP address 137.99.11.9).1 It iteratively receives a request datagram containing a 32-bit integer representing a social security number

  All the new strings generated

Explain why, if on some round, all the new strings generated for any syntactic category are longer than s, and s has not already been generated for L(), then s cannot ever be put in L(). Hint: Use Exercise 11.3.5.

  Write the two redox half-reactions

How would I write the two redox half-reactions for these: Ag/Ag+| | H+/H2 Cu/Cu2+| | H+/H2 H2/H+| | Zn2+/Zn

  Write a program in c that arranges and prints out

When playing poker and other card games (standard 52 cards, excluding the jokers), it is usual to arrange a hand to reflect its values. Write a program in C that arranges and prints out a random hand of ten cards in sorted order by pips values.

  Which of the following is a pure abstract function

Which of the following is a pure abstract function?

  What happens when c is a function of just one variable

What happens when C is a function of just one variable? Can you provide a geometric interpretation of what gradient descent is doing in the one-dimensional case?

  The overloaded assignment operator.

You have a class called MyBag that contains this partial implementation of the overloaded assignment operator.  The first line is missing.

  Average and maximum error

The program uses the average and maximum error of the two values. c.

  Define and implement a default constructor for robot class

Define and implement a default constructor for the Robot class that sets the locations to zero, and load to false (no load is being carried by the Robot)

  Computer programming techniques

Construct a program from a design and use appropriate functions

  Before each sort, write psudo-code

Ceate a single cpp ?le (FILE=MAIN2.cpp) containing all three elementry sorts(bubble, insertion, selection). Before each sort, write psudo-code and invarient analysis of the sort in block comment style. Add the code from 3.). Generate a list of 100..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd