0
I need help with this question. What are the three errors and their corrections? I don't really understand the code
avg is supposed to: receive any (undetermined) number of parameters of type double, compute, and return their average. Find and fix 3 errors to make this method works properly. public static double avg(double numbers) { double s; for (double v: numbers) s += v; return s/numbers.size(); }
2 odpowiedzi
+ 5
Maryam Magdy ,
before we are going to help you, you should put some more effort in solving the task. it looks like that this is a homework or something like this.
so it's up to you now step in and start. (there is a java code in your codebits. is this code done by yourself?)
happy coding!
+ 3
As the function should take multiple numbers, it should take a double array instead of a single double. The sum variable s should explicitly start off with 0