subject
Computers and Technology, 08.05.2021 01:00 jfjhbc

The code below defines a method to sum the elements of an array of ints. Re-write the loop using a while loop instead of a for loop. The string for must not appear anywhere in your answer (even in a comment) int sumElements(int[] data){
int total = 0;
for (int i = 0; i < data. length; i++){
total += data[i];
}
return total;
}

For example:

Test Result
int[] data = new int[]{10,20,-5,100};
System. out. println(sumElements(data));
125
int[] data = new int[]{};
System. out. println(sumElements(data));
0

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 06:20
Which text function capitalizes the first letter in a string of text? question 10 options: upper capital first proper
Answers: 1
question
Computers and Technology, 24.06.2019 00:40
What social factors affect your health
Answers: 3
question
Computers and Technology, 24.06.2019 01:00
The initial tableau of a linear programming problem is given. use the simplex method to solve it. x 1 x 2 x 3 s 1 s 2 z 1 2 4 1 0 0 8 3 4 1 0 1 0 10 minus3 minus12 1 0 0 1 0 the maximum is nothing when x 1equals nothing, x 2equals nothing, x 3equals nothing, s 1equals3, and s 2equals0. (be sure to simplify to lowest terms if necessary.)
Answers: 2
question
Computers and Technology, 24.06.2019 08:20
Which type of entity describes a fundamental business aspect of a database? a. linking b. lookup c. domain d. weak
Answers: 3
You know the right answer?
The code below defines a method to sum the elements of an array of ints. Re-write the loop using a w...
Questions
question
Advanced Placement (AP), 12.11.2019 05:31
Questions on the website: 13722361