Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Location
    SoCal
    Posts
    2
    Rep Power
    0

    Default Help with class project, random number generator.

    Finished. Thanks.
    Last edited by Christopher The Great; 03-13-2009 at 07:05 PM.

  2. #2
    bobix is offline Member
    Join Date
    Mar 2009
    Posts
    2
    Rep Power
    0

    Default

    Here is a simple solution:

    import java.util.Random;

    public class RandomNumber {

    /**
    * @param args
    */
    public static void main(String[] args) {

    Random generator = new Random();
    int a = generator.nextInt(50);
    int b = generator.nextInt(50);
    int c = generator.nextInt(50);

    System.out.println(a+" "+b+" "+c);
    if ( (a<b) && (a<c) )
    System.out.println(a);
    if ( (b<a) && (b<c) )
    System.out.println(b);
    if ( (c<a) && (c<b) )
    System.out.println(c);

    }

    }

  3. #3
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    You just want to generate three random numbers. Assign them into three variables, and compare with each other.

  4. #4
    Join Date
    Mar 2009
    Location
    SoCal
    Posts
    2
    Rep Power
    0

    Default

    I got mine to work with a good bit of tweaking and adding. Thanks for the help.
    Last edited by Christopher The Great; 03-13-2009 at 07:05 PM.

  5. #5
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

Similar Threads

  1. Replies: 8
    Last Post: 04-19-2009, 05:50 PM
  2. Random Shape generator
    By scheng12 in forum New To Java
    Replies: 1
    Last Post: 03-09-2009, 02:06 AM
  3. Random number help
    By jgonzalez14 in forum New To Java
    Replies: 5
    Last Post: 09-16-2008, 09:13 AM
  4. Replies: 3
    Last Post: 05-27-2008, 01:51 PM
  5. Random Generator
    By padutch2 in forum New To Java
    Replies: 1
    Last Post: 12-03-2007, 06:43 PM

Posting Permissions

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