id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

middleValue


Given an array of integers, return the middle value if the length is odd, return the average of the two middle values if the length is even, and return zero if the length is zero.


middleValue([9, 8, 6, 9, 9]) → 6.0
middleValue([2, 5, 2, 4, 3, 5, 2]) → 4.0
middleValue([1, 6, 5, 4, 7, 2]) → 4.0

...Save, Compile, Run (ctrl-enter)

double middleValue(int[] a) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 200

Copyright Nick Parlante 2017 - privacy