maurice malone

Greenhorn
+ Follow
since Dec 06, 2006
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by maurice malone

Hi,

I am currently working on a project and was looking for some assistance in completing it. The project is for school and consist of coding a stats class that contains a number of statistical functions.

Below is the info.

Project Summary
Code a java class named "Stats" that includes the following "statistical" methods. Each of these methods accepts an int array as an input parameter and calculates a specific statistical value. The input parameter "int n" is used to pass the number of elements in the array that you should use in your calculations.

int Maximum( int ar[], int n)
{
// returns the maximum element value in the array "ar"
}
int Minimum(int ar[], int n)
{
// returns the minimum element value in the array "ar"
}
float Mean(int ar[], int n)
{
// returns the mean value for the array ar"
}
float Median(int ar[], int n)
{
// returns the median value for the array "ar"
}
float StandardDeviation( int ar[], int n)
{
// returns the standard deviation for the array "ar" (use formula below)
}

The main function
Your main function is used to call your statistical functions. It is up to you to generate some test data and check to make sure your methods work correctly. You do not have to provide code in your main() function when you turn in this project. The code for you main() function will be provided by the grading program.

Processing
The processing for each method is yours to figure out, however your methods should be able to handle an input array consisting of any number of elements.

What I have coded so far is here:
// Stats.Java
// Statistical calculator

public class Stats
{
//returns the Maximum value in the array "ar"
int Maximum( int ar[], int n)
{
// n = no of elements in array
int max =ar[0];
for ( int i=0; i<n; i++)
{
if ( ar[i] > max ) max = ar[i];
}
return max;
}

//returns the Minimum value in the array "ar"
int Minimum( int ar[], int n)
{
// n = no of elements in array
int min =ar[0];
for ( int i=0; i<n; i++)
{
if ( ar[i] < min ) min = ar[i];
}
return min;
}
//returns the Median Value for the array "ar"


//returns the Mean Value for the array "ar"


//returns the Standard Deviation for the array "ar"

//Data to test scropt that is not going to be included in final project
public static void main(String[] args)
{
int array [] = {10, 20, 30, 40, 50};
}
}

The main is not to be included in the submitted work but should be used to test the functions that I have so far. Any assistance will be greatly appreciated. I want to make sure I am on the right track. I used visual basic for the first section and am pretty new to java.

Mc
17 years ago