Answer:
The complete method is as follows:
public static int divBySum(int[] arr, int num){
int sum = 0;
for(int i:arr){
if(i%num == 0)
sum+=i;
}
return sum;
}
Explanation:
As instructed, the program assumes that arr has been declared and initialized. So, this solution only completes the divBySum method (the main method is not included)
This line defines the method
public static int divBySum(int[] arr, int num){
This line declares and initializes sum to 0
int sum = 0;
This uses for each to iterate through the array elements
for(int i:arr){
This checks if an array element is divisible by num (the second parameter)
if(i%num == 0)
If yes, sum is updated
sum+=i;
}
This returns the calculated sum
return sum;
}
Your answer would be D everyone has a different situation of cyberbullying
I would say B would be the best answer choice out of the given choices
Answer:
The function in Python is as follows:
def digitSum( n ):
if n == 0:
return 0
if n>0:
return (n % 10 + digitSum(int(n / 10)))
else:
return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))
Explanation:
This defines the method
def digitSum( n ):
This returns 0 if the number is 0
<em> if n == 0:
</em>
<em> return 0
</em>
If the number is greater than 0, this recursively sum up the digits
<em> if n>0:
</em>
<em> return (n % 10 + digitSum(int(n / 10)))
</em>
If the number is lesser than 0, this recursively sum up the absolute value of the digits (i.e. the positive equivalent). The result is then negated
<em> else:
</em>
<em> return -1 * (abs(n) % 10 + digitSum(int(abs(n) / 10)))</em>
Answer:
This allowed different kinds of computers on different networks to "talk" to each other. ARPANET and the Defense Data Network officially changed to the TCP/IP standard on January 1, 1983, hence the birth of the Internet. All networks could now be connected by a universal language.