Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: im in a hurry!!Help with a programm..java game of guessing a word

  1. #1
    Junior Member
    Join Date
    Oct 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default im in a hurry!!Help with a programm..java game of guessing a word

    Hello im new in java , i have developed a code but i think it contains too many errors.

    I have to design a java game based on guessing a word.

    The game has 3 guesses which are randomly choosen, and every one of those has a current answer.



    for example:

    "shines and is yellow and roundround "

    (secret answer: sun)



    "Its cold and light"

    (secret answer: snow)

    "It has strings and a woman shape"

    (secret answer: guitar)


    Once one of the three keys is choosen randomly the user has 3 chances to be able to guess the right word, after the 3rd time the game has to display "you have lost"

    If you guess the right word within the 3 chances give there has to be displayed the phrase,
    "congratulations you have won"


    here is the code:

    import static java.lang.System.out;
    import java.util.Scanner;
    import java.util.Random;
    class guess {
    public static void main(String[] args) {
    String arr_keys[] = { // guesses
    "shines and is yellow and looks round",
    "Its cold and light"
    "It has strings and a woman shape",
    };
    String arr_ans[] = { // answers
    "sun",
    "snow",
    "guitarl"
    };
    int numIntentos = 0;
    Scanner miScanner = new Scanner(System.in);
    int numRandom = new Random(). nextInt(3) ;

    //System.out.println("Random: " + numRandom);
    System.out. println ("********************************************" );
    System.out. println ("welcome \"This is guess the word game!!\"");
    System.out. println ("********************************************" );
    System.out. println ();
    System.out. println ("guess the following...");
    System.out. println (arr_keys[numRandom]);
    System.out. println ("********************************************" );
    System.out. println ("type your answer: ");
    String sTexto = miScanner.next();
    numIntentos++;



    if (sTexto.equals(arr_ans[numRandom])) {
    System.out. println ("you have won ");

    }
    else {
    System.out. println ("try again ");
    }


    }
    Last edited by mr_doctor; October 13th, 2010 at 08:30 AM.


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: im in a hurry!!Help with a programm..java game of guessing a word

    I'm sure the word is supercalifragilisticexpialidocious. What did I win?

    How To Ask Questions The Smart Way

    db

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Default Re: im in a hurry!!Help with a programm..java game of guessing a word

    Might help if you posted the code?

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: im in a hurry!!Help with a programm..java game of guessing a word

    Quote Originally Posted by mr_doctor View Post
    im in a hurry!!
    Aw man, I did have a full solution all coded for you. But when I realized you were in such a hurry, I knew I was probably too late, so I deleted it. Sorry I couldn't get it to you in time to reach your deadline.

Similar Threads

  1. Word filter assignment help
    By normandygahn in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 15th, 2010, 07:42 AM
  2. Replies: 1
    Last Post: May 3rd, 2010, 01:03 PM
  3. begginer wondering why his guessing game won't work
    By Ligawulf in forum What's Wrong With My Code?
    Replies: 2
    Last Post: March 8th, 2010, 12:22 AM
  4. How to invert a word String
    By Truffy in forum Java Programming Tutorials
    Replies: 16
    Last Post: October 3rd, 2009, 02:44 AM
  5. Replies: 1
    Last Post: November 22nd, 2008, 01:32 PM