Write a game program guess which tries to guess

Assignment Help Computer Engineering
Reference no: EM13322627

Write a game program guess which tries to guess what number you have chosen in as few guesses as possible. It can only ask you whether the number is less than some other number. The dialog on the console panel should look something like this:

Choose a number between 0 and 16.

Is it less than 8? y

Is it less than 4? n

Is it less than 6? n

Is it less than 7? n

Your number is 7.

The expected user inputs are y for "yes" and n for "no".

You will want to keep track of the range of numbers that might have been chosen based on the answers that have been given so far until there is only one number left. You can approximately divide an integer by 2 by right-shifting it by one bit.

*NOTE: the program is the one doing the guessing while the user is the one who inputs a number 0-16 for the computer to guess.

 

Reference no: EM13322627

Questions Cloud

Find period of vibration and max acceleration of cylinder : A 30 lb uniform cylinder can roll without sliding on a 15 degree incline. A belt is attached to the rim of the cylinder, and a spring holds the cylinder at rest. If the center of the cylinder is moved 2 in.
What is the resistance of the car : A toy car is driven by a battery of 9V. it draws a current of 2mA. what is the resistance of the car
Write mips assembly language program to recursively compute : Write a MIPS assembly language program to recursively compute the nth term of Perrin's sequence. n will be input from the keyboard.
Define what is the initial pressure of h2s in the flask : An empty 5.00- flask is charged with 0.450g of pure H2S(g) , at 25 degrees celsius What is the initial pressure of H2S(g) in the flask
Write a game program guess which tries to guess : You will want to keep track of the range of numbers that might have been chosen based on the answers that have been given so far until there is only one number left. You can approximately divide an integer by 2 by right-shifting it by one bit.
What is the wavelength of the light in air : A glass sheet measuring 10cm X 25cm is covered by a very thin opaque coating. In the middle of this sheet is a thin, What is the wavelength of the light in air
What is the chlorine concentration when the tank is put back : A water tower containing 4000 m3 of water has been taken out of service to install a chlorine monitor. The concentration of chlorine in the water tower was 2.0 mg/L when the tower was taken out of service.
Benefits of enterprise agreements : Outline and analyse the nature, methods and benefits of enterprise agreements in enhancing workplace productivity.
Determine a sorption coefficient for the soil at the site : Chromium contamination is a problem at a number of hazardous-waste sites. At one site local concentrations of chromium reached 60,000 mg chromium/kg soil and 19,000 mg/L chromium in the water.

Reviews

Write a Review

 

Computer Engineering Questions & Answers

  Questions on risc machine

Questions on RISC machine

  Use an x, y translation transform

Several multi exposure image sequences (of three images) will be released on the day the assignment is marked.

  Multiplexer and decoder

A bus organized the CPU has 32 registers with 16 bits in each, an ALU and a destination decoder. Specify how many multiplexers are there within the bus, and specify the size of each multiplexer?

  Writing into file utilizing fileinputstream

Write down an application utilizing the FileInputStream which opens a file which consists of the name of user's favourite book and then show it to the user.

  Provides an introduction to relational databases

Solution gives an introduction to relational databases and Microsoft Access. It defines relational databases and describes some of the basics of creating relational databases.

  For benefit of upper management that is non-technical

What edition of Windows 2003 server would you use for your domain controller? If you required four way clustering for Sherrill's Web server, what edition of Windows Server 2003 would you use.

  Application to computer science

Find the matrices that represent the relations.

  How can translate into the broader area of business ethics

What responsibility do computing professionals have to society at large and to other members in their profession.how can translate into the broader area of business ethics.

  Write down a program using the vector class

create a program using vector class that allows the user to input the number of days worked in a 7 day workweek and, using a fixed hourly rate, calculates the weeks wages and the average number of hours worked per day.

  What many regard as preferential treatment from the courts

What are the major similarities and differences between the juvenile and adult justice systems in the U.S. and should juveniles continue to receive what many regard as preferential treatment from the courts Why or why not

  The dice in a craps round is called the "come out roll"

In the game of Craps, a "Pass Line" bet proceeds as follows. Using two six-sided dice, the first roll of the dice in a craps round is called the "Come Out Roll". The bet immediately wins as the come out roll is 7 or 11, and loses when the come out..

  Algorithm for carrying out concatenation operation

Develop an algorithm that concatenates T1 and T2 into the single binary search tree. The worst case running time must be O(h), where h is the maximum of h1 and h2, the heights of T1 and T2.

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