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.


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

Results 1 to 2 of 2

Thread: Help with this program.

  1. #1
    Junior Member
    Join Date
    Oct 2011
    My Mood
    Thanked 0 Times in 0 Posts

    Default Help with this program.

    Write a program that generates a random number between 1 and 10, then asks a player to guess your number. The player should be given three tries to guess your number.

    Each time the player guesses, you should give them some feed back. Let them know if their guess was too high, or too low, or if they won the game!

    When the player guess correctly the game is over, don't keep asking them to guess. And remember,after three wrong guesses, the computer wins!

    I have this so far which I just started. I need everything input/output in pop boxes(JOptionPane)

    import javax.swing.JOptionPane;

    public class GuessingGame {
    public static void main (String [] args) {

    int num1 = (int) (System.currentTimeMillis()%10);

    String answer = JOptionPane.showInputDialog(null,"Guess a number between 1 and 10");


  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 636 Times in 540 Posts

    Default Re: Help with this program.

    Quote Originally Posted by valenciajv View Post
    I have this so far which I just started.
    And what's your question? Seems like a reasonable start. We won't do your homework for you.

    Keep plugging away, and I recommend you follow these steps: http://www.javaprogrammingforums.com...e-posting.html
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Help with class program!!! STUCK! Program not doing what I Want!!!
    By sketch_flygirl in forum What's Wrong With My Code?
    Replies: 7
    Last Post: April 4th, 2011, 07:29 AM