Menu

[Solved]Java Implement Selfdot Method Takes Input Array Integers Returns Sum Elements Squared Exam Q37074723

Java

Implement the selfDotmethod below, which takes as input an array of integers and returnsthe sum of each of the elements squared. An examplemain method, as well as corresponding output, issupplied – you cannot change this method, and the output when theprogram is run must conform exactly to the sample output.

/* sample run:

First selfdot is 14

Second selfdot is 125

*/

public static void main(String args[]) {

   int nums1[] = {1, 2, 3};

   int nums2[] = {10, 5};

  

   System.out.print(“First selfdot is”);      

   System.out.println(selfDot(nums1)); // 1*1+ 2*2 + 3*3

   System.out.print(“Second selfdot is”);

   System.out.println(selfDot(nums2)); //10*10 + 5*5

}

// put your selfDot method here

Expert Answer


Answer to Java Implement the selfDot method below, which takes as input an array of integers and returns the sum of each of the el… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *