![Computers and Technology](/tpl/images/cats/informatica.png)
Computers and Technology, 31.03.2021 01:50, akdubgirlp7pe1v
Please help me with this coding problem :)
Consider the following field and incomplete method of some class. The method calcTotal is intended to return the sum of all values in vals.
private int[] vals;
public int calcTotal()
{
int total = 0;
/* missing code */
return total;
}
Which of the code segments shown below can be used to replace /* missing code */ so that calcTotal will work as intended?
I.
for (int i : vals)
{
total += i;
}
II.
for (int pos = vals. length; pos > 0; pos--)
{
total += vals[pos];
}
III.
int pos = 0;
while (pos < vals. length)
{
total += vals[pos];
pos++;
}
I only
II only
I and III
II and III
III only
![answer](/tpl/images/cats/otvet.png)
Answers: 1
Other questions on the subject: Computers and Technology
![image](/tpl/images/cats/informatica.png)
![image](/tpl/images/cats/informatica.png)
Computers and Technology, 24.06.2019 08:30, ladybuggirl400
@josethesolis i need can anyone text me and follow me
Answers: 1
![image](/tpl/images/cats/informatica.png)
Do you know the correct answer?
Please help me with this coding problem :)
Consider the following field and incomplete method of so...
Questions in other subjects:
![Konu](/tpl/images/cats/istoriya.png)
History, 06.01.2020 17:31
![Konu](/tpl/images/cats/es.png)
![Konu](/tpl/images/cats/geografiya.png)
Geography, 06.01.2020 17:31
![Konu](/tpl/images/cats/mat.png)
Mathematics, 06.01.2020 17:31
![Konu](/tpl/images/cats/mat.png)
Mathematics, 06.01.2020 17:31
![Konu](/tpl/images/cats/istoriya.png)
History, 06.01.2020 17:31
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
![Konu](/tpl/images/cats/mat.png)
Mathematics, 06.01.2020 17:31
![Konu](/tpl/images/cats/ekonomika.png)
Business, 06.01.2020 17:31