Pastebin (save as RNGG.java and compile)
My problem is that it compiles okay, but when I run it it just goes blank. What have I done wrong?
I'm trying to create a Number Guessing Game (between 1 and 100), that runs for as many times as the user wants (by a variable declared by the user at the beginning), then stops and prints how many times it has been used, at the end (after both the while and for loop).
So the simple algorithm is:
GET INPUT ROUND;
For every (ROUND) {
While (the user hasn't guessed the random number) {
print either 'HIGHER' or 'LOWER';
// and guess again
}
}
print ROUND;
Thanks for your help ;)
5 replies to this topic
#1
Posted 13 December 2010 - 10:22 PM
|
|
|
#2
Posted 13 December 2010 - 10:35 PM
By the way this has colouring for java syntax:
Java | /* * To change this template, choose Tools | Tem - LavaCoder
Java | /* * To change this template, choose Tools | Tem - LavaCoder
#3
Posted 14 December 2010 - 07:32 AM
The program works fine for me. Keep in mind that at the start you need to input a number to indicate how many rounds you want to play.
#4
Posted 14 December 2010 - 11:24 AM
Yea, Xylyze is right. At first i also thought it went blank.. untill i realised it's waiting for a number :c-^_^:
#5
Posted 14 December 2010 - 12:19 PM
Haha wow it's doing what I programmed it to do, silly me! Thanks guys! Peace, love, and hippies.
#6
Posted 19 December 2010 - 07:38 PM
Why do you have the "i" variable decrement every time the user guesses something greater than 100? Wouldn't that allow her to have a negative value for the number of guesses that she's had? And, why not establish a value for your guess variable before you test it?
Edited by Liars_paradox, 19 December 2010 - 08:10 PM.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









