Write method called median that accepts an array of integer

Assignment Help JAVA Programming
Reference no: EM13161737

Write a method called median that accepts an array of integers as its parameter and returns the median of the numbers in the array. The media is the number that appears in the middle of the list if you arrange the elements in order. Assume that the array is of odd size (so that one sole element constitutes the median) and that the numbers in the array are between 0 and 99 inclusive. For example, the median of [5, 2, 4, 17, 55, 4, 3, 26, 18, 2, 17] is 5 and the median of [42, 37, 1, 97, 1, 2, 7, 42, 3, 25, 89, 15, 10, 29, 27] is 25.

Write a method that uses Arrays.sort() to sort the array into ascending order and then calculate the median. Call the method from a main program that allows the user to specify the size of the array and then enter the array elements. The method returns the median to the main program and the main program prints out the median.

 

 

Reference no: EM13161737

Questions Cloud

What is the average response time for this system? : A web server receives a request every 50ms and processes web requests every 8 ms. Using queuing theory, 1. What is the average response time for this system?
Java''s type int has limit onhow large aninteger it can store : Java's type int has a limit on how large an integer it can store. This limit can be circumvented by representing an integer as an array of digits. Write an interactive program that adds two integers of up to 50 digits each.
Your letterinventory class must use an array : Your LetterInventory class must use an array of Counter objects. Note that there is no nextChar method in the Scanner class. You must use the next() method and then use a loop through the characters of the token that is returned. Ignore any character..
Pointer variables to demonstrate shallow and deep copy : Using C++, write a program that uses pointer variables to demonstrate shallow and deep copy. The program should give the user the choice to do the following:
Write method called median that accepts an array of integer : Write a method called median that accepts an array of integers as its parameter and returns the median of the numbers in the array.
If interest is compounded annually : If interest is compounded annually, it grows as follows. Suppose P0 is the initial amount and INT is the interest rate per year. If P1 and P2 represent the balance at the end of the first and second year
Demonstrate the construction and output of an array : In fluid mechanics, the Reynolds number (Re) is a dimensionless quantity that is used to help predict similar flow patterns in different fluid flow situations. For example, Reynolds numbers can be computed for different velocities of fluid flow over ..
Ask the user how many times you want to run : c the algorithm. 2. Then choose a word at random from the array of Strings as the target (Use the integer random number generator)
Build a table of reynolds numbers at flow velocities : Write a program code to compute and build a table of Reynolds numbers at flow velocities varying from 100 to 1000 ft/sec (at increments of 100)

Reviews

Write a Review

JAVA Programming Questions & Answers

  Java program to print strings given at command line

Write down program Average.java to print strings which it is given at command line, one per line. If nothing is given at command line, then print "No arguments".

  Client server monitoring system project design

client server monitoring system project design. The server adminstation can send messages to the clients and DESIGN WITH JAVA NETBEANS AND GUI.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Java program editing

Prompt the user for the student's score and put that value into an object

  Java program that will prompt the user to input a file

Write a Java program that will prompt the user to input a file (document) in order to count the frequency of each word. This program will display the frequency of each word sorted alphabetically or by frequency (depending on the preference of the use..

  Develop a gui based java program

Designing and developing a College Registration program

  Print the contents of the array

Prepare a second loop that prints the contents of the array

  Implementation activities of software development

Analysis, design, and implementation activities of software development

  The string class and/or the stringbuffer class in java

Create a simple Java application that uses the String class and/or the StringBuffer class and at least 4 of the class methods. Show the code, demonstrate it works properly and describe what it is doing.

  Design and implement an applet called circles

Design and implement an applet called Circles that draws 50 circles of random diameter in random locations. If the diameter of a circle is less than a certain value, the circle is ?lled with the color yellow.

  Tracer for java

Implementation of a tracer of Java objects and the tracer can be invoked from any point of a Java program, accepting an object as argument.

  Function using javascript syntax to compute gross pay

Write a function using JavaScript syntax to compute a person's gross pay for a week. The function must receive the number of hours worked and the rate of pay per hour.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd