Challenge: Array Statistics
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 4
single
Spør AI
Spør AI
Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår
Fantastisk!
Completion rate forbedret til 8.33
Challenge: Array Statistics
Sveip for å vise menyen
Oppgave
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
Alt var klart?
Takk for tilbakemeldingene dine!
Seksjon 2. Kapittel 4
single