Java Program: Numbers game

timer Asked: Jan 6th, 2013

Question Description

this program must be written in java.

in a game of guessing numbers, one person says "i am thinking of a number between 1 and 100".  the second person guesses "50". the first person says "no it is less".  the second person guesses "20".  the first person says "no it is greater".  this continues until the second person guesses the number.  write a program that plays this game.  the computer knows the number (a random number between 1 and 100).  the user (the second person) is the guesser. at the end of the program, the computer must displays the number of guesses it took the user to guess the number.

the program must include:

                                a main class

a loop (for, while or do-while)

an if or if – else statement

must accept input from the keyboard

must have a prompting statement

a separate class with a constructor

at least one method that performs an operation required by the main program

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


here is an algorithm, please make it as simple as you can and still include the necessary rules.

·         prompt

·         generate a random number (1-100)

computer = gen random # (1-100)

do (input number (kb reader)

stop = false;


if (mynum = computenum

stop = true


(system.out.println(“you win!”);



if (mynum>computenum)


system.out.println(“your number is too high);



if (mynum<computenum)


system.out.println(“your number is too low”);



This question has not been answered.

Create a free account to get help with this and any other question!

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors