only how to print the box plot choose between the two
i already have all the code except this one
in java
Write a class called ArrayStats that has the following characteristics
Instance Variables
Methods
An Example of a Box Plot will be given in class. An Ascii Box Plot may look something like this:
Given a Five Number Summary of 10, 25, 45, 60, 65 |--------------------|--------------| --------------| | |----- |--------------------|--------------| ---------------------------------------------------------------------------------------------------- 1 100
Submit your code via canvas as usual. Make sure to document your code appropriately.
import java.util.*;
import java.lang.*;
public class ArrayStats
{
int a[];
Random r = new Random(); //creating random object to generate
random numbers
public ArrayStats() //default consturctor which creates array of
random numbers between 1 and 100.
{
a=new int[100];
for(int i=0;i<100;i++)
{
a[i]=r.nextInt(100-0) + 0;
}
}
public ArrayStats(int size,int min,int max) //parameter constructor
which creates array of random numbers between min and max using
given size.
{
a=new int[size];
for(int i=0;i<size;i++)
{
a[i]=r.nextInt(max-min) + min;
}
}
public int getMean(int []a)
{
int mean,sum=0;
for(int i=0;i<a.length;i++) //finding the sum of array of
elements.
sum=sum+a[i];
mean=sum/a.length; //finding the average.
return mean;
}
public void sortArray(int []a)
{
for (int i = 0; i < a.length-1; i++) //sorting the array using
bubble sort.
for (int j = 0; j < a.length-i-1; j++)
if (a[j] > a[j+1])
{
// swap temp and arr[i]
int temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
public int getMedium(int []a)
{
sortArray(a);
int medium,middle=a.length/2;;
if(a.length%2==0)
{
medium=(a[middle-1]+a[middle])/2;
}
else
{
medium=a[middle];
}
return medium;
}
public int getMode(int []a)
{
int maxValue = 0, maxCount = 0;
for (int i = 0; i < a.length; ++i)
{
int count = 0;
for (int j = 0; j < a.length; ++j)
{
if (a[j] == a[i])
++count;
}
if (count > maxCount) //finding the higher freqency
element
{
maxCount = count;
maxValue = a[i];
}
}
return maxValue;
}
public int square(int num)
{
num = num * num;
return num;
}
public double getStandardDeviation(int []a)
{
double sd=0.0;
for (int i = 0; i < a.length; i++) //finding the standard
deviation
{
sd += square(a[i] - getMean(a)) / a.length;
}
double standardDeviation = Math.sqrt(sd);
return standardDeviation;
}
int median(int[] a, int l, int r)
{
int n = r - l + 1;
n = (n + 1) / 2 - 1;
return n + l;
}
public int[] get5numberSummary(int []a)
{
sortArray(a);
int array[]=new int[5];
int mid_index = median(a, 0, a.length);
int Q1 = a[median(a, 0, mid_index)]; //finding first quartile
value
int Q3 = a[median(a, mid_index + 1, a.length)]; //finding third
quartile value
array[0]=a[0];
array[1]=Q1;
array[2]=getMedium(a);
array[3] =Q3;
array[4]=a[a.length-1];
return array;
}
public String toString(int[] a) //toString function to print all
the values
{
int result[]=new int[5];
result=get5numberSummary(a);
return
"\nMean:"+getMean(a)+"\nMedium:"+getMedium(a)+"\nMode:"+getMode(a)+"\nStandard
Deviation:"+getStandardDeviation(a)+"\n------------------------\n5NumberSummary:"+"\nMinimum:"+result[0]+"\nFirst
Quartile:"+result[1]+"\nMedium:"+result[2]+"\nSecond
Quartile:"+result[3]+"\nMaximum:"+result[4];
}
public static void main(String[] args)
{
ArrayStats as=new ArrayStats(10,10,50); //cretting object of class
ArrayStats (size=10,min=10,max=50).
System.out.println(as.toString(as.a)); //calling the toString
function by passing the array.
}
}
only how to print the box plot choose between the two i already have all the...
C langauge Please. Complete all of this please. Thanks :) Statistical Analysis Write a program that creates an array of 10 integers. The program should then use the following functions: getData() Used to ask the user for the numbers and store them into an array displayData() Used to display the data in the array displayLargest() Used to find and display the largest number in the array (prior to sort). displaySmallest() Used to find and display the smallest number in the...
I need help making this work correctly. I'm trying to do an array but it is drawing from a safeInput class that I am supposed to use from a previous lab. The safeInput class is located at the bottom of this question I'm stuck and it is not printing the output correctly. The three parts I think I am having most trouble with are in Bold below. Thanks in advance. Here are the parameters: Create a netbeans project called ArrayStuff...
Please post screenshots only File Tools View CMSC 140 Common Projects Spring 2019(1) E - 3 x Project Description The Powerball game consists of 5 white balls and a red Powerball. The white balls represent a number in the range of 1 to 69. The red Powerball represents a number in the range of 1 to 26. To play the game, you need to pick a number for each ball in the range mentioned earlier. The prize of winning the...
pls help java ASAP!!!!!!! Topic String Tokenizer Static Methods Static Variables Primitive Arrays Description Enhance the last assignment by providing the following additional features: (The additional features are listed in bold below) Class Statistics In the class Statistics, create the following static methods (in addition to the instance methods already provided). • A public static method for computing sorted data. • A public static method for computing min value. • A public static method for computing max value. • A...
Hi i will give you a thumbs up if you do this problem correctly. Sorting Analysis Code and Essay Due: 4/22/2019(Monday) Introduction And now for something completely different. Different sorting algorithms are better for different size data sets. Other sorting algorithms are better for data sets of a specific type – for instance, data that is already ordered. In this assignment you will implement four different sorting algorithms and collect statistics for each of those algorithms while sorting multiple different...
Could anyone help add to my python code? I now need to calculate the mean and median. In this programming assignment you are to extend the program you wrote for Number Stats to determine the median and mode of the numbers read from the file. You are to create a program called numstat2.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The...
In java language here is my code so far! i only need help with the extra credit part For this project, you will create a Rock, Paper, Scissors game. Write a GUI program that allows a user to play Rock, Paper, Scissors against the computer. If you’re not familiar with Rock, Paper, Scissors, check out the Wikipedia page: http://en.wikipedia.org/wiki/Rock-paper-scissors This is how the program works: The user clicks a button to make their move (rock, paper, or scissors). The program...
C Programming write two functions, similar to what you see in the sample program. The first will ask the user to enter some information (I have included the type in parentheses) First Name (char[]) Last Name (char[]) Age (int) Height in Inches (double) Weight in Pounds (double) You will use pass-by-reference to modify the values of the arguments passed in from the main(). Remember that arrays require no special notation, as they are passed by reference automatically, but the other...
Please help with the following, I have already done most of them. Please verify Question1 Select one answer The histogram below displays the distribution of so ages at death due to trauma (unnatural accidents and homicides) that were observed in a certain hospital during a week. opoints 18 16 14 12 10 а» 10 20 30 40 50 60 70 80 90 Age Which of the following are the appropriate numerical measures to describe the center and spread of the...
Copy the following java codes and compile //// HighArray.java //// HighArrayApp.java Study carefully the design and implementation HighArray class and note the attributes and its methods. Create findAll method which uses linear search algorithm to return all number of occurrences of specified element. /** * find an element from array and returns all number of occurrences of the specified element, returns 0 if the element does not exit. * * @param foundElement Element to be found */ int findAll(int...