Question: 1.8 StdlntArray.allof Add a function called allOf to stdIntArray which returns true if all the array or sub-array elements match the given value, and false

 1.8 StdlntArray.allof Add a function called allOf to stdIntArray which returns

1.8 StdlntArray.allof Add a function called allOf to stdIntArray which returns true if all the array or sub-array elements match the given value, and false otherwise.There should be two versions, one that works with the entire array, and one that works with sub-array defined by a half-open range. The signatures should be: public static boolean allof (int a[, int value) public static boolean allof (int a[, int lo, int hi, int value) The version that works with the entire array should call the sub-array version, just like we did in class with the other stdIntArray functions For example, assume that array a-42, 42, 42 andb -(1, 1, 4, 9, 9, 5, 7, 5}. Then allof (a, 42) returns true allof (a, 3) returns false allof (b, 1) returns false allof (b, 9) returns false allof (b, 5) returns false allof (b, 0, 2, 1) returns true allof (b, 0, 3, 1) returns false allof (b, 3, 5, 9) returns true allof (b, 3, 4, 9) returns true allof (b, 3, 6, 9) returns false allof (b, 5, 6, 5) returns true allof (b, 5, 8, 5) returns false allof (b, 0, 0, 1) returns true allof (b, 0, 0, 42) returns true allof (b, 8, 8, 42) returns true Note that testing an empty range always returns true. You may find this surprising (you'll learn why this is in Discrete Math), but you'll also find that, if you write the function in the simplest and most obvious way, it works out rather nicely Your function may assume that 0 lo h a.length

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!