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

  The actual solution of the equation shall be done

The actual solution of the equation shall be done by a function named equSolver(), which takes three coefficients as parameters and returns a structure of three fields: two roots (if they exist) and a boolean indicator, whether the roots do exist.

  Write a powershell script that contains cmdlets

Assignment : Write a PowerShell script that contains cmdlets (no aliases) that meets the following requirements: Create an script named xyz123_AD.ps1 that accomplished the following: Create user1_StudentID throughuser10_StudentID where StudentID is..

  Make a game in which you guess a number

Make a game in which you guess a number between two set numbers to find the answer, the game should tell you if you are too low in your guess or too high. For example

  Make a function in dr racket

Make a function in Dr Racket that consumes a string and figures out if it starts with a specific letter of the alphabet - Can you help me how should I go about this? Please any ideas?

  1 write a c program that takes an eastern standard time

1. write a c program that takes an eastern standard time in hours minutes and secondsand prints it out in central

  How do you access the memory address of a variable

How do you access the memory address of a variable? How do you access the contents of the memory location whose address is stored in a pointer variable?

  Program to play lottery

The program randomly generates a Lottery of a three-digit number ( any number from 100 to 999), prompts the user to enter a three-digit number, and determines whether the user wins according to the subsequent rule:

  Design customized mailing lists for marketing department

Marketing department requires to be able to design customized mailing lists, to send different messages to different types of donors. What system will best meet these requirements?

  Generate two files of 100 by 100 mazes

Write a C++ program that opens a file representing an encoded maze and reads it

  You should use pure recursive calls

You should use pure recursive calls completely and count the number of calls the program makes. You should count how many times recursive calls were made.

  Write a recursive function squares

Write a recursive function squares that takes a list of numbers, and returns a new list of the squares of those numbers.

  Write a c++ program containing a linked list of 10 integer

Write a C++ program containing a linked list of 10 integer numbers. Have the program display the numbers in the list.

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