lete method to create an array of random integers. Method Specification The method takes in three integer parameters: the array size, the lower bound, and the upper bound. The method also takes in a boolean parameter. The method creates and returns an integer array of the specified size that contains random numbers between the lower and upper bound., using these rules: The lower bound is always inclusive. If the boolean parameter is true, the up
Java:
Write a complete method to create an array of random integers.
Method Specification
The method takes in three integer parameters: the array size, the lower bound, and the upper bound. The method also takes in a boolean parameter.
The method creates and returns an integer array of the specified size that contains random numbers between the lower and upper bound., using these rules:
- The lower bound is always inclusive.
- If the boolean parameter is true, the upper bound is also inclusive.
- If the boolean parameter is false, the upper bound is not inclusive (meaning it is exclusive).
If any of the parameters are invalid, null is returned.
Driver/Tester Program
I have provided you with a driver/tester program that you can use to test your code before submitting. Paste your code into the placeholder at the top of the file. Review the Homework FAQ page, which contains instructions and a video of how to use the provided file. If you aren't sure how to use the tester or have any questions, post to the discussion board!
I strongly recommend running this program before you submit your homework. The program is designed to help you catch common errors and fix them before submitting. Run the program multiple times since random number selection is involved. Each time, review the output to see if your actual results match what was expected. A "**********TEST FAILED" message should also print if a test case fails.
The driver program has some tester methods at the end. These method are used to streamline the running of multiple repeated tests. You don't need to understand, review, or modify these methods.
Driver program:
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images