Question: Write a method named range that takes an array of integers as a parameter and returns the range of values contained in the array. The

 Write a method named range that takes an array of integers

Write a method named range that takes an array of integers as a parameter and returns the range of values contained in the array. The range of an array is defined to be one more than the difference between its largest and smallest element. For example, if the largest element in the array is 15 and the smallest is 4, the range is 12. If the largest and smallest values are the same, the range is 1. The followings show some calls to the method and their results: intul al = {15, 22, 8, 19, 31); range (al) returns 24 into a2 = {3, 10000000, 5, -29, 4); range (22) returns 10000030 intIl a3 = 1100, 5) range (a3) returns 96 int[] a4 = 132); range (a4) returns 1

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!