Challenge: Array Statistics
Uppgift
Swipe to start coding
Write two methods to calculate statistics for an array of integers. The first method should return the sum of all elements in the array. The second method should return the average value of the array as a double.
- The
CalculateSummethod must return the sum of all elements in thenumbersarray. - The
CalculateAveragemethod must return the average of the elements in thenumbersarray as a double. - If the
numbersarray is empty,CalculateAveragemust return0.0.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 4
single
Fråga AI
Fråga AI
Fråga vad du vill eller prova någon av de föreslagna frågorna för att starta vårt samtal
Fantastiskt!
Completion betyg förbättrat till 8.33
Challenge: Array Statistics
Svep för att visa menyn
Uppgift
Swipe to start coding
Write two methods to calculate statistics for an array of integers. The first method should return the sum of all elements in the array. The second method should return the average value of the array as a double.
- The
CalculateSummethod must return the sum of all elements in thenumbersarray. - The
CalculateAveragemethod must return the average of the elements in thenumbersarray as a double. - If the
numbersarray is empty,CalculateAveragemust return0.0.
Lösning
Var allt tydligt?
Tack för dina kommentarer!
Avsnitt 2. Kapitel 4
single