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

  Create program that uses functions and reference parameters

Create program that uses functions and reference parameters, and asks user for the outside temperature.

  Write a program using vectors and iterators

Write a program using vectors and iterators that allows a user to maintain a personal list of DVD titles

  Write the code required to analyse and display the data

Calculate and store the average for each row and column. Determine and store the values for the Average Map.

  Write a webservices application

Write a webservices application that does a simple four function calculator

  Iimplement a client-server of the game

Iimplement a client-server version of the rock-paper-scissors-lizard-Spock game.

  Model-view-controller

Explain Model-View-Controller paradigm

  Design a nested program

How many levels of nesting are there in this design?

  Convert celsius temperatures to fahrenheit temperatures

Write a C++ program that converts Celsius Temperatures to Fahrenheit Temperatures.

  Evaluate and output the value in the given base

Write C program that will input two values from the user that are a Value and a Base with which you will evaluate and output the Value in the given Base.

  Design a base class shape with virtual functions

Design a base class shape with virtual functions

  Implementation of classes

Implementation of classes Chart and BarChart. Class barChart chould display a simple textual representation of the data

  Technical paper: memory management

Technical Paper: Memory Management, The intent of this paper is to provide you with an in depth knowledge of how memory is used in executing, your programs and its critical support for applications.

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