Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java question, thx Write the program array tool described below. Test with sever

ID: 3837409 • Letter: J

Question

Java question, thx Write the program array tool described below. Test with several values for "cutOffValue" to ensure that your program works. We now want to do some simple array manipulations. We are going to write a new program ArrayTool which can do a few things on arrays. We are interested in arrays of double. Specifically, we will use the following array in this program: double [] valuesArray; valuesArray = new double [] { 100.0, 34.0, 72.0, 56.0, 82.0, 67.0, 94.0}; We can base our code on the class sort provided above. The first step is to create a method printHigherorLower which has two parameters, one array of double xs, and one value cutOffvalue of type double. So the declaration of the method is as follows: public static void printHigherorLower(doubleu [] xs, double cutOffValue){//code goes here } This method goes through the values stored in "xs", from the first one to the last one, and prints for each value a message stating if that value is lower or higher than the parameter "cutoffvalue" For example, with the array "valuesArray" above, and a "cutoffvalue" of 72.5, the method will print: The entry 0 (100.0) is higher than 72.5 The entry 1 (34.0) is lower than 72.5 The entry 2 (72.0) is lower than 72.5 The entry 3 (56.0) is lower than 72.5 The entry 4 (82.0) is higher than 72.5 The entry 5 (67.0) is lower than 72.5 The entry 6 (94.0) is higher than 72.5

Explanation / Answer

ArrayTool.java


public class ArrayTool {

  
   public static void main(String[] args) {
       double[] valuesArray;
       valuesArray = new double[] {100.0, 34.0, 72.0, 56.0, 82.0, 67.0, 94.0};
       double cutOffValue = 72.5;
       printHigherOrLower(valuesArray, cutOffValue);
   }
   public static void printHigherOrLower(double[] xs, double cutOffValue){
       for(int i=0;i<xs.length;i++){
           if(xs[i]< cutOffValue){
               System.out.println("The entry "+i+" ("+xs[i]+") is lower than "+cutOffValue);
           }
           else if(xs[i]>cutOffValue){
               System.out.println("The entry "+i+" ("+xs[i]+") higher than "+cutOffValue);
           }
           else{
               System.out.println("The entry "+i+" ("+xs[i]+") is equals to "+cutOffValue);
           }
       }
   }

}

Output:

The entry 0 (100.0) higher than 72.5
The entry 1 (34.0) is lower than 72.5
The entry 2 (72.0) is lower than 72.5
The entry 3 (56.0) is lower than 72.5
The entry 4 (82.0) higher than 72.5
The entry 5 (67.0) is lower than 72.5
The entry 6 (94.0) higher than 72.5

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote