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 3 of 3

Thread: Anyone would like to help me? I really need your help???

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

    Default Anyone would like to help me? I really need your help???

    Task:
    1.) Write a Java class that generates a random integer (between 1 and 250). Call the
    class GenKeys. GenKeys should have a least one method that returns the integer
    random number. Gen Keys should not have a main method.

    2.) Write a Java Program called MainProg that does have a main method. This class
    should create an instance of GenKeys and use it to randomly generate integers.
    We will call these integers keys.

    3.) MainProg should write keys, each on their own line, in a file called “keys.txt”.
    Ultimately your program should generate and write to file 500 keys.

    4.) MainProg should then read all of the keys from “keys.txt”, and store them in an
    array, removing any duplicates. (In other words if the number 55 is generated
    twice, only one of these 55’s should be added to the array). Note that your final
    array will contain less than 500 keys. Now, write the remaining keys into a file
    called “sorted.txt”, one key per line, with the smallest number on the first line
    and the largest file on the last line.

  2. #2
    Senior Member PhHein's Avatar
    Join Date
    Mar 2013
    Location
    Germany
    Posts
    609
    My Mood
    Sleepy
    Thanks
    10
    Thanked 93 Times in 86 Posts

    Default Re: Anyone would like to help me? I really need your help???

    This is not a code mill. What have you tried? - Matt Gemmell

  3. The Following User Says Thank You to PhHein For This Useful Post:

    pbrockway2 (May 3rd, 2013)

  4. #3
    Member
    Join Date
    Feb 2013
    Posts
    40
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Anyone would like to help me? I really need your help???

    To randomly generate a number between 1 and 250 you type Math.random()*249+1