Question: Lab Description Write several methods to perform basic operations on arrays. Sample Input: See the main of labl7a. Files Needed: ArrayTools.java ArrayToolsRunner.java Sample Output Original



Lab Description Write several methods to perform basic operations on arrays. Sample Input: See the main of labl7a. Files Needed: ArrayTools.java ArrayToolsRunner.java Sample Output Original array [2, 4, 6, 8, 10, 12, 8, 16, 8, 20, 8, 4, 6, 2, 2] Sum of 0-3: 12 Sum of 2-7: 44 Sum of 1-8: 64 Sum of 5-9: 44 Count of 2s: 3 Count of 8s: 4 import static java.lang.System.*; import java.lang.Math; import java.util.Arrays; public class ArrayToolsRunner public static void main( String args) int[1 theRay2,4,6,8,10,12,8,16, 8,20,8,4,6,2,2); out.println( "Original array"+Arrays.toString(theRay)) out.println("Sum of 0-3: "ArrayTools. sumSection (theRay, 0,3)) //add more test cases public class ArrayTools //instance variables and constructors could be present, but are not necessary //sumSection will return the sum of the numbers //from start to stop, not including stop public static int sumSection(int] numArray, int start, int stop) int sum-0 return sum; //countVal will return a count of how many times val is present in numArray public static int countVal (int[] numArray, int val) int count 0; return count
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
