subject

I'm trying to create a java program using arraylists to find the median of the list. The lists can be either even or odd in length. If the list is even in length then I take the greater median value. This is what I have so far

int go( List list )
{

Collections. sort(list);

int middle = list. size() / 2;
int size = list. size() % 2;
int midplus = middle + 1;

if (size == 1)
{
return list. get(middle);
}
else
{
return list. get(midplus);
}

}

I keep getting an ArrayIndexOutOfBounds exception and I do not know why.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:10
Select the correct answer. emma, the quality control manager in a software development company, asks the testing team to check whether the user interface is friendly. to which type of testing is emma referring? a. usability testing b. data comparison c. validation testing d. stress testing e. destruction testing
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Write a full class definition for a class named player , and containing the following members: a data member name of type string .a data member score of type int .a member function called setname that accepts a parameter and assigns it to name . the function returns no value.a member function called setscore that accepts a parameter and assigns it to score . the function returns no value.a member function called getname that accepts no parameters and returns the value of name .a member function called getscore that accepts no parameters and returns the value of score .this is what i have, aparently this is wrong: class player{private: string name; int score; public: void player: : setname (string n){name =n; }void player: : setscore (int s){score = s; }string player: : getname (){return name; }int player: : getscore (){return score; }};
Answers: 2
question
Computers and Technology, 23.06.2019 08:00
Match the items with their respective descriptions.
Answers: 1
question
Computers and Technology, 23.06.2019 10:00
Now, open this passage to read about fafsa requirements. describe the information you will need to provide in order to complete a fafsa. list at least three of the required documents you must include.
Answers: 3
You know the right answer?
I'm trying to create a java program using arraylists to find the median of the list. The lists can b...
Questions
question
Mathematics, 25.04.2020 01:40
question
Mathematics, 25.04.2020 01:41
question
Social Studies, 25.04.2020 01:41
Questions on the website: 13722367