1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
stiks02 [169]
3 years ago
15

The divBySum method is intended to return the sum of all the elements in the int array parameter arr that are divisible by the i

nt 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)
Computers and Technology
1 answer:
iragen [17]3 years ago
8 0

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;

   }

You might be interested in
What was the in-app phrase listed as SC answer? <br> A) MasterCard <br> B) No fee<br> C) Apple Pay
likoan [24]

Answer:

A.master card

Explanation:

masterCard because

6 0
3 years ago
Read 2 more answers
2.Consider the following algorithm and A is a 2-D array of size ???? × ????: int any_equal(int n, int A[][]) { int i, j, k, m; f
Elis [28]

Answer:

(a) What is the best case time complexity of the algorithm (assuming n > 1)?

Answer: O(1)

(b) What is the worst case time complexity of the algorithm?

Answer: O(n^4)

Explanation:

(a) In the best case, the if condition will be true, the program will only run once and return so complexity of the algorithm is O(1) .

(b) In the worst case, the program will run n^4 times so complexity of the algorithm is O(n^4).

5 0
4 years ago
f the copyright date on the homepage is more than 1 year old, the website should always be considered unmaintained
Lilit [14]
We still have moderators who watch the site every day they are in the process of acquiring a new one 
4 0
3 years ago
Jim is an experienced security professional who recently accepted a position in an organization that uses Check Point firewalls.
Contact [7]

Answer: D) CCSA

Explanation: THE CHECKPOINT CCSA(CERTIFIED SECURITY ADMINISTRATOR) is a computer based certification offered by different Computer Institutions in order to equip computer experts or systems engineers on the activities or process or knowledge needed to enhance the security domain of computer systems.

Check Point Firewall is a component of the Software Blade architecture which provides advanced firewall features like VPN and mobile device connectivity.

5 0
4 years ago
You want to drive traffic to a new landing page for a campaign, and want a web address that's short, easy to remember, trackable
Akimi4 [234]

Hootsuite supports you with vanity URLs.

1. vanity URLs

<u>Explanation:</u>

Since the website webpage is landing on campaign, heavy network traffic is expected. Better to have multiple URL methods but it will not solve the purpose of heavy of network access of webpage or web site. Better to use vanity URLS methods to use heavy network traffic.

Vanity URLS means is customizable redirecting or rerouting by branding links or customized URL link. These type of vanity URLS by choosing hosting service and customize link been created. So end user can use link.

6 0
3 years ago
Other questions:
  • Write a multi-paragraph Informational essay about a current event in the news. You can develop your topic using
    8·2 answers
  • Fazer um programa em C++ que contenha 3 funções sendo:
    11·1 answer
  • A manufacturer of machine tools creates a spreadsheet of tools and their cost. The spreadsheet has four fields: name of the tool
    10·2 answers
  • Most of us have been using elements of Web 2.0 without even realizing it.<br> True<br> False
    6·1 answer
  • import java.util.Scanner; public class ArraySum { public static void main(String[] args) { Scanner scnr = new Scanner(System.in)
    9·1 answer
  • What breakthrough in sound recording facilitated stereophonic recording? Ο Α. overdubbing O B. multitrack recording O C. digital
    10·1 answer
  • Write three statements to print the first three elements of vector runTimes. Follow each with a newline. Ex: If runTimes = {800,
    8·1 answer
  • How i simplify this boolean expression ?A'.B'.C'+A'.B'.C+A'.B.C+A.B'.C+A.B.C
    6·2 answers
  • Discuss how social media can affect social movements and social change.
    13·2 answers
  • What would a good digital citizen do if he sees his classmate left her email account open on a school computer by mistake?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!