Jump to content

Problem With my Class.

- - - - -

  • Please log in to reply
5 replies to this topic

#1
lavaCode

lavaCode

    Newbie

  • Members
  • Pip
  • 4 posts
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 ;)

#2
lavaCode

lavaCode

    Newbie

  • Members
  • Pip
  • 4 posts
By the way this has colouring for java syntax:
Java | /* * To change this template, choose Tools | Tem - LavaCoder

#3
Xylyze

Xylyze

    Newbie

  • Members
  • Pip
  • 8 posts
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
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Yea, Xylyze is right. At first i also thought it went blank.. untill i realised it's waiting for a number :c-^_^:

#5
lavaCode

lavaCode

    Newbie

  • Members
  • Pip
  • 4 posts
Haha wow it's doing what I programmed it to do, silly me! Thanks guys! Peace, love, and hippies.

#6
Liars_paradox

Liars_paradox

    Newbie

  • Members
  • PipPip
  • 15 posts
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