Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,208,017 members, 8,001,117 topics. Date: Wednesday, 13 November 2024 at 12:54 AM

Please HELP Me With This Java Program - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / Please HELP Me With This Java Program (1682 Views)

How To Compile And Run Java Program By Notepad / Help Me Solve This Java Regex Problem (2) (3) (4)

(1) (Reply) (Go Down)

Please HELP Me With This Java Program by Vectormike(m): 11:19am On Jun 09, 2017
Write a Java program to calculate mean and standard deviation of 20 numbers
Re: Please HELP Me With This Java Program by Nobody: 2:42pm On Jun 09, 2017
Vectormike:
Write a Java program to calculate mean and standard deviation of 20 numbers

I even have an assignment on this too
Re: Please HELP Me With This Java Program by Sirnuel: 2:07pm On Jun 10, 2017
/**
* Method to get the mean of n numbers
* @param numbers - array of numbers
* @return computed mean
*/
public static double getMean(double [] numbers){
double sum = 0;
double mean = 0.0;

//return 0 if there is no number
if(numbers.length < 1)
return 0.0;

//get the sum of the numbers
for(int i = 0; i < numbers.length; i++){
sum = numbers[i] + sum;
}

//calculate the mean
mean = sum/numbers.length;

return mean;
}

/**
* Method to return the standard deviation of n numbers
* @param numbers - a double[] array of numbers
* @return computed standard deviation
*/

public static double getStandardDeviation(double [] numbers){
//Instantiate variables
double sum = 0;
double mean = 0.0;
double variance = 0.0;
double standardDeviation = 0.0;

if(numbers.length < 1)
return 0.0;

//calculate the mean
//return 0 if there is no number
if(numbers.length < 1)
return 0.0;

//get the sum of the numbers
for(int i = 0; i < numbers.length; i++){
sum = numbers[i] + sum;
}

//calculate the mean
mean = sum/numbers.length;

//reset sum to 0;
sum = 0;
//using the computed mean, calculate for the standard deviation
for(int n = 0; n < numbers.length; n++){
double temp = Math.pow(numbers[n] - mean, 2);
sum = temp + sum;
}

//calculate the varianceb
variance = sum/numbers.length;

//calcualte the standard deviation
standardDeviation = Math.sqrt(variance);

return standardDeviation;
}

3 Likes

Re: Please HELP Me With This Java Program by kevindd: 8:07pm On Jun 28, 2017
I have been trying to learn Java for a long time but can't handle it, unfortunately... Now I need to create a web app for my business website and I am looking for some good developers currently. I guess I will use the help of the developers from https://www.issart.com/en/lp/java-development-team/java-expertise/se for this job. They seem to be nice specialists. Maybe you guys can help me with it too?
Re: Please HELP Me With This Java Program by Dangujba1111: 5:48am On Jun 30, 2017
I wrote this for school assignment it has GUI where you put any number call me to know where i can share it for you 07032966865
Re: Please HELP Me With This Java Program by MediaTools: 4:57pm On Jun 04, 2020
Use this mean calculator to compute the arithmetic mean from a set of numerical values. Data is from: Population Sample Enter comma separated data

(1) (Reply)

What Is The Difference Between Web Design And Web Programming / C Please Help / C Sharp Questions? Which Guru Can Write This Program???

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 11
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.