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: java help needed urgently :(

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post java help needed urgently :(

    Write a program that generates random numbers:
    a) Write a method that returns a random integer in the range of 1 to 100.
    b) Then add another method that takes a parameter specifying the top number – i.e. if you pass it 50 it returns a random number between 1 and 50. Test your random method and make sure it works.
    c) Write another method so that you pass it two values – the top and bottom of the range you want the highest value from – i.e. if you pass it 10 and 20 it returns a random number between 10 and 20.
    d) Then write another method so that if repeatedly called it doesn’t return two numbers the same? So once a random number has been generated and returned, the method doesn’t return that number again. To do this you will have to store every number generated.
    Do each method in turn and then test that it works by calling it from the main method (I don’t mean write a test plan), again no need for user input. So you should end up with a single class (the main can go in it) with four other methods – each one implementing the functionality described above.

    someone help me please


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java help needed urgently :(

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: java help needed urgently :(

    ive done the first bit but i dnt know how to get it regenerate another ramdom number if its over 50

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: java help needed urgently :(

    how to get it regenerate another ramdom number if its over 50
    Use an if statement to test if it's over 50. Or a do{} while statement depending on what the code is doing.
    Post the code you are having problems with.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. A java question - Help Urgently needed?
    By dripnoodle in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 3rd, 2012, 03:57 PM
  2. need help urgently!!
    By kimwheeler in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 1st, 2011, 07:22 AM
  3. JAVA Coder required urgently-paid
    By sam_java in forum Paid Java Projects
    Replies: 2
    Last Post: January 15th, 2011, 04:04 AM
  4. Help needed urgently!!!
    By sonia11 in forum Loops & Control Statements
    Replies: 1
    Last Post: October 19th, 2010, 04:19 PM
  5. Reading from a text file. Help needed urgently.
    By TheAirPump in forum File I/O & Other I/O Streams
    Replies: 2
    Last Post: December 14th, 2009, 06:16 PM