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

I need help finishing steps 3-7 of the following two JAVA programs. /** ArrayOpe

ID: 3825151 • Letter: I

Question

I need help finishing steps 3-7 of the following two JAVA programs.

/**

   ArrayOperations class

   Chapter 8, Programming Challenge 10

*/

public class ArrayOperations

{

   /**

   STEP1:    getTotal method.

       @param array An array of doubles.

       @return The total of the values stored in the

       argument array.

   */

public double getTotal(double[] array){

double sum=0.0;

for(int i=0; i<array.length; i++)

{sum+=array[i];}

return sum;}

   /**

   STEP2:   getAverage method

       @param array An array of doubles.

       @return The average of the values stored in the

       argument array.

   */

public double getAverage(double[] array1){

double average=getTotal(array1)/array1.length;

return average;}

   /**

   STEP3:   getHighest method

       @param array An array of doubles.

       @return The highest value in the argument array.

   */

public double getHighest(double[] array2){

  

}

/**

   Demo program for the ArrayOperations class

   Chapter 8, Programming Challenge 10

*/

import java.util.Scanner;

public class ArrayOperationsDemo

{

   public static void main(String[] args)

   {

       // Some arrays of various types.

       //step4: Declare an 5-element double array

  

       Scanner scan = new Scanner(System.in);

// Process the array.

       //step5: declare an object for array operation

  

       //step6: find the sum of the above array and print the result.

       //step7: find the highest value in the above array and print the result.

   }

}

Explanation / Answer

ArrayOperations.java


import java.util.Scanner;


public class ArrayOperations
{

/**
STEP1: getTotal method.
@param array An array of doubles.
@return The total of the values stored in the
argument array.
*/
public double getTotal(double[] array){
double sum=0.0;
for(int i=0; i<array.length; i++)
{sum+=array[i];}
return sum;}



/**
STEP2: getAverage method
@param array An array of doubles.
@return The average of the values stored in the
argument array.
*/
public double getAverage(double[] array1){
double average=getTotal(array1)/array1.length;
return average;
}

/**
STEP3: getHighest method
@param array An array of doubles.
@return The highest value in the argument array.
*/
public double getHighest(double[] array2){
double max = array2[0];
for(int i=0; i<array2.length; i++){
   if(max < array2[i]){
       max = array2[i];
   }
}

return max;

  
}

public static void main(String[] args)
{
// Some arrays of various types.
//step4: Declare an 5-element double array
  
   double arr[] = new double[5];
Scanner scan = new Scanner(System.in);
// Process the array.
for(int i=0; i<arr.length; i++){
   System.out.println("Enter the value "+(i+1)+": ");
   arr[i] = scan.nextDouble();
}
//step5: declare an object for array operation
ArrayOperations obj = new ArrayOperations();

//step6: find the sum of the above array and print the result.
System.out.println("Sum: "+obj.getTotal(arr));
System.out.println("Average: "+obj.getAverage(arr));
//step7: find the highest value in the above array and print the result.
System.out.println("Highest value: "+obj.getHighest(arr));  

}
}

Output:

Enter the value 1:
44
Enter the value 2:
33
Enter the value 3:
11
Enter the value 4:
55
Enter the value 5:
22
Sum: 165.0
Average: 33.0
Highest value: 55.0

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