Question: Please write code in Java using the following templates //ArrayTools.java public class ArrayTools { //instance variables and constructors could be present, but are not necessary
Please write code in Java using the following templates
//ArrayTools.java
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;
}
}
//ArrayToolsRunner.java
//(c) A+ Computer Science
//www.apluscompsci.com
//Name -
import static java.lang.System.*;
import java.lang.Math;
import java.util.Arrays;
public class ArrayToolsRunner
{
public static void main( String args[] )
{
int[] theRay = {2,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
out.println("Sum of 3-6: " + ArrayTools.sumSection(theRay,3,6));//30
out.println("Count of 4s: " + ArrayTools.countVal(theRay, 4)); //2
}
}

Lab Goal: The lab was designed to teach you more about parameters. Lab Description : Write several methods to perform basic operations on arrays. Sample Input: See the main of labl7a. \begin{tabular}{l} Files Needed :: \\ ArrayTools.java \\ ArrayToolsRunner \\ \hline . java \end{tabular} Sample Output : original array : [2,4,6,8,10,12,8,16,8,20,8,4,6,2,2] Sum of 03:12 Sum of 27:44 Sum of 18:64 Sum of 5-9: 44 Count of 2s:3 Count of 8s:4
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
