...

View Full Version : i need help with my guessing game Please !!



6omba7la
12-10-2007, 07:17 PM
Hello everyone

my java gussing game dosent work and i dont know what the problem is please i would really appreciate the help thank you





import java.util.Scanner;
class Guess
{
public static void main (String[] args)
{
int random = 1 +(int)(Math.random() * 100);
Scanner guess = new Scanner (System.in);
int found = 0;
int answer;
int x=1;
answer = guess.nextInt();

do {
System.out.print("count is: " + random);

if ( answer > 100 )
System.out.println("\n" +answer+" is an invalid number.\n");

else if ( answer < x )
{
System.out.println("\nGoodbye\n");
found = 1;
}

else if ( answer < random )
System.out.println("\n Guess "+answer+" is LOW.\n");
}
else if ( answer > random )
System.out.println("\nGuess "+answer+" is HIGH.\n");
}
else if ( answer = x )
{
System.out.println("\nYou are right\n");
found = 1;
}
while ( random <= 101)
found <= 101;
System.out.print("thanks , bye");
{
{
{

brad211987
12-11-2007, 01:49 AM
By it doesn't work, what do you mean? Doesn't compile? Doesn't provide the correct output? Is this a homework assignment?

From just eye-balling your code, there is one obvious problem, your closing brackets are actually opening brackets. On your last 3 lines you have:

{
{
{

These should face the other direction.

Gox
12-12-2007, 10:44 AM
...I hope no one saw what I previously had here as I need to learn to read it seems :)

Anywho, as Brad said, we'd like to know what problems your program has so we can offer some help.

Also, can you explain what the line "found <= 101;" is suppose to do?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum