subject

The divBySum method is intended to return the sum of all the elements in the int array parameter arr that are divisible by the int parameter num. Consider the following examples, in which the array arrcontains {4, 1, 3, 6, 2, 9}. The call divBySum(arr, 3) will return 18, which is the sum of 3, 6, and 9, since those are the only integers in arr that are divisible by 3.
The call divBySum(arr, 5) will return 0, since none of the integers in arr are divisible by 5.
Complete the divBySum method using an enhanced for loop. Assume that arr is properly declared and initialized. The method must use an enhanced for loop to earn full credit.
/** Returns the sum of all integers in arr that are divisible by num
* Precondition: num > 0
*/
public static int divBySum(int[] arr, int num)

ansver
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 00:20, kcameronanderso
What’s resistance in an electrical circuit ?
Answers: 1
image
Computers and Technology, 22.06.2019 14:30, megkate
Complete the sentence based on your knowledge of the professional difficulties faced by music artists. digital technology allows audiences to see free live telecasts of music or dance performances through
Answers: 1
image
Computers and Technology, 22.06.2019 18:30, smariedegray
All of the following are characteristics that must be contained in any knowledge representation scheme except
Answers: 3
image
Computers and Technology, 23.06.2019 02:00, kelseybell5522
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 1
You know the right answer?
The divBySum method is intended to return the sum of all the elements in the int array parameter arr...

Questions in other subjects: