TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prime b
NA
810
345k
Standard deviation
Apr 22 2012 2:55 PM
I need to calculate standard deviation , and I cant figure out how to do it =(
I have all kind of variables you need, average of all numbers , sum of all numbers.
int sum=0;
int average = 0;
int highestNumber = 0;
int lowestNumber = 0;
final int matchedNumber = 500;
final int lessThan = 1000;
boolean found = false;
int countLessThan= 0;
int countAverage = 0;
int limit = 10000;
int[] array = new int[limit];
Random gen = new Random();
for(int index=0; index < array.length; index++)
{
// random values generated
array[index] = gen.nextInt(10001 - 1+ 1) + 1;
// sum of all numbers in array
sum += array[index];
// average of all numbers
average = sum / array.length;
//Highest number
if(array[index]> highestNumber)
{
highestNumber = array[index];
}
if(array[index] < lowestNumber)
{
lowestNumber = array[index];
}
if(matchedNumber == array[index])
{
found = true;
}
if(array[index]< lessThan)
{
countLessThan++;
}
if(array[index]<average)
{
countAverage++;
}
}
System.out.println("The sum of all numbers is "+sum);
System.out.println("The average of all numbers is "+average);
System.out.println("The highest number is "+highestNumber);
System.out.println("The lowest number is "+lowestNumber);
System.out.println("Is there a numer 500 in array? "+found);
System.out.println("There are "+countLessThan+" numbers less than 1000");
System.out.println("There are "+countAverage+" numbers less than average");
Reply
Answers (
3
)
Conversion of windows console Application to Windows Phone Application
how to set output path and assembly name properties