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

Thread: HELP!

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HELP!

    3. Tremor!

    Write a program to create an integer array of size 20. Then, the program should generate and insert random integers between 1 and 5, inclusive into the array. Next, the program should print the array as output.

    A tremor is defined as a point of movement to and fro. To simulate it, the program will generate a random number between 0 and 19, which represents the location in the array (i.e. index number). Then, the 3 numbers to the left and right of this location should be reset to the value 0. If there isnít 3 numbers to the left and right you may assume a lesser number depending on the boundaries of the array.

    Then, the final array should be printed as output. There is no user input for this program.

    Your program must include, at least, the following methods:

    ē insertNumbers, which will take as input one integer array and store the random numbers in it.
    ē createTremor, which will generate the random number as the location and return it.

    A sample run of the program is shown below:

    Sample output #1:
    Array: 1 2 2 3 1 5 4 2 3 4 4 2 1 1 3 2 1 4 3 2 1
    Random position: 5
    Final Array: 1 2 0 0 0 5 0 0 0 4 4 2 1 1 3 2 1 4 3 2 1

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,082
    My Mood
    Mellow
    Thanks
    184
    Thanked 653 Times in 640 Posts

    Default Re: HELP!

    Thread closed as homework dump with no effort.