Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Dec 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    i need help with my guessing game Please !!

    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


    PHP Code:

    import java
    .util.Scanner;
    class 
    Guess
    {
      public static 
    void main (String[] args)
      {
        
    int random +(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 )
         {
           
    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 )
         {
           
    System.out.println("\nYou are right\n");
           
    found 1;
          }
          while ( 
    random <= 101)
            
    found <= 101;
          
    System.out.print("thanks , bye");
         {
       {      
     { 
    Last edited by Aradon; 12-11-2007 at 01:34 AM.

  • #2
    Regular Coder brad211987's Avatar
    Join Date
    Sep 2005
    Location
    Ohio
    Posts
    631
    Thanks
    10
    Thanked 50 Times in 50 Posts
    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.

  • #3
    Gox
    Gox is offline
    Regular Coder Gox's Avatar
    Join Date
    May 2006
    Location
    Ontario, Canada
    Posts
    392
    Thanks
    2
    Thanked 20 Times in 20 Posts
    ...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?
    Last edited by Gox; 12-12-2007 at 10:48 AM. Reason: Learning to read


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •