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
Displays information a bout drivers, network connections, and other program-related details.
slava [35]

Answer:

library

Explanation:

hope you like it

6 0
3 years ago
What is the influence of new technology on society?
sweet [91]

Answer:

E. New technology is beneficial but can also be used in a detrimental way.

Explanation:

New technology such as cryptocurrency (powered by blockchain technology) can be regarded as a welcome development that has benefited the society in so many good ways. However, cryptocurrency as a new technology also has disadvantages it presents to the society. One of such negative influence cryptocurrency has is that it can be used for illicit activities such as money laundering, funding terrorism and so on.

So, in summary, we can conclude that:

"New technology is beneficial but can also be used in a detrimental way."

5 0
2 years ago
What is data consolidation?
Katarina [22]
<span>Data consolidation is the gathering and/or integration of data coming from many and diverse  sources and going into a single destination. Meanwhile this process is taking place,  different data sources are consolidated, into a single data store.

Hope this helps.</span>
8 0
3 years ago
Which is the best web development company in Pakistan?
andriy [413]

Answer:

Arbisoft is listed as the top cpmpany.

Explanation:

The top 5 are:

Arbisoft

Cygnis Media

Tintash

Square63

OneByte

4 0
3 years ago
"You have an interface on a router with the IP address of 192.168.192.10/29. Including the router interface, how many hosts can
SSSSS [86.1K]

Answer:

6 hosts can have IP addresses on the LAN attached to the router interface

Explanation:

Given IP address

=> 192.168.192.10/29

It has a subnet mask of /29 which means it has 3 host bits. This is calculated by subtracting 29 from 32(number of bits in an IPV4)

Since there are 3 host bits,  the total number of possible addresses is given by

=> 2^{3} = 8 possible addresses.

Out of these 8 possible addresses, the first address will be the subnet id and the last address will be the broadcast address.

Therefore, there are only 6 addresses available for the hosts.

<em>Hope this helps!</em>

5 0
3 years ago
Other questions:
  • Computer World sells laptops separately from accessory products like docking stations, anti-virus software, and external hard dr
    6·1 answer
  • Trading your bicycle for a snowboard exemplifies ?
    15·1 answer
  • WILL GIVE BRAINLIEST TO FIRST AND BEST ANSWER!
    10·1 answer
  • Rapid development programming languages eliminate the possibility of having bugs in code. True or False
    8·1 answer
  • What is a slide master ?
    8·2 answers
  • How is kerning used in Word?
    7·2 answers
  • Sarah has prepared a project document about the small and medium-sized companies in the United States. While proofreading, she r
    11·2 answers
  • How can i fix a all white phone screen
    11·2 answers
  • Question 2
    7·1 answer
  • I have a question, but it's not a math question. Can anyone give me 5 unblockers for school computers? If you answer this, you w
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!