Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java code b. find the mean and median of 20 numbers. To find a median you need to sort the 20 numbers first. You can

Java code

b. find the mean and median of 20 numbers. To find a median you need to sort the 20 numbers first.

You can use any of the sort codes posted in 'Array with Sort' post to sort the 20 numbers in your Array.

Next is to write a code to find the median of the sorted 20 numbers. Remember, your median is the

two central numbers of the 20 sorted numbers.

Below is the hint pseudocode:

if(size % 2 == 0) //if the size of the list is even; median would be the average of the two middle numbers

median = (nums[(size / 2)] + nums[size / 2 - 1]) / 2.0; //locate the subscripts of the 2 middle numbers; addition of their values/2

else

median = nums[size / 2] / 1.0; // if the size of the list is odd; median would be 1 middle number

if(size != 0)

mean = total * 1.0 / size;

System.out.println("The mean is " + mean + " and the median is " + median);

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

6. Is all Internet training the same? Explain.

Answered: 1 week ago