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
KIM [24]
3 years ago
5

We have written a method called sum with an int[] parameter nums. We want our sum method to compute the sum of nums, but our cod

e has a bug (or perhaps bugs?) in it.
Fix the bugs.

Computers and Technology
1 answer:
ira [324]3 years ago
8 0

Answer:

Following are the code to this question:

public class Main//defining a class-main  

{

public static int sum(int[] nums)//defining a method sum that accepts array  

{

int total = 0;//defining integer variable total

for(int num : nums) // use for-each loop

{  

total += num;//add array value in total variable

}

return total;//use return keyword to return the total value

}

public static void main(String []ar )//defining a main method  

{

int[] nums={1,2,3,4,5};//defining 1-D array nums

System.out.println(sum(nums));//use print function to call sum method  

}

}

Output:

15

Explanation:

In the class "Main", a static method, "sum" is defined, that accepts array in its parameter and inside the method, an integer variable "total" is define, that uses the for each loop to add array value in a total variable and use a return keyword to return its value.  

Inside the main method, an integer array nums are defined, that holds store some values and use the print function to call the sum method.

You might be interested in
PLEASE HELP ANSWER THIS only if you know BOTH ANSWERS!
Leya [2.2K]

Answer:

For the first question I think it is chains

The second question.

The woman is suspicious at hotel doors have numbers so how could he have been confused

Explanation:

8 0
3 years ago
Read 2 more answers
What is the HTML tag used to define a block of content?<br> O <br> O class<br> O #id<br> O
allsm [11]
Are there any other options
7 0
2 years ago
Read 2 more answers
You are responsible for the administration of your Windows Server 2016 DNS server, which is installed on a domain controller as
kvv77 [185]

Answer:

A. domain adminsb because maybe it might be the right answer.

8 0
3 years ago
Memorex Disks sells computer disk drives with right-of-return privileges. Returns are material and reasonably predictable. Memor
pychu [463]

Memorex should: iv. record a refund liability in the year of the sale.

<h3>What is a right-of-return privilege?</h3>

A right-of-return privilege can be defined as a special right, advantage or entitlement that is accorded to a customer, which avails them an opportunity to return a product they have purchased.

Since Memorex Disks offers its customers right-of-return privileges, it is expected that it should record a refund liability in the year of the sale i.e recording an allowance for sales returns in the year the sale was made.

Read more on right-of-return privilege here: brainly.com/question/17165436

#SPJ1

5 0
2 years ago
Two electronics technicians are measuring electrical quantities in circuits. Technician A says that copper, glass, porcelain, an
OleMash [197]

The correct answer is A. Only technician B is correct because I don't believe carbon is form of resistors.


8 0
3 years ago
Read 2 more answers
Other questions:
  • The CPU is referred to as the ______ of the computer.
    14·2 answers
  • Are the actions legal or illegal?
    13·1 answer
  • Which statement is NOT CORRECT?
    11·1 answer
  • Describe three perimeter intrusion detection systems and give an example of one that you have seen deployed either at work or an
    8·1 answer
  • Brake fluid should be checked __________.
    8·2 answers
  • Define client and.server​
    13·1 answer
  • You have a team member on a remote project who is not fluent in English and
    15·1 answer
  • What is the most common type of storage device for transferring files from one computer to another?
    10·1 answer
  • Create a function that takes an integer array as input and a value and returns a POINTER to the number of times the value appear
    13·1 answer
  • 11:25
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!