Results 1 to 4 of 4
- 05-29-2008, 02:10 AM #1
Member
- Join Date
- Mar 2008
- Posts
- 8
- Rep Power
- 0
standard deviation and mean for an array
hey everyone, i just started doing arrays and the program i'm trying to create is supose to take 8 random numbers from the user then calculates the standard deviation, and the mean and provide the standard scores, right now i'm have 6 errors because of the array. The error are are saying ; epected at the end of the method, but i did that and it doesn work. if you can help if would be greatly appreciated!!! :)
here's my code do far
PHP Code:import java.util.Scanner; public class Statistics { public static void main(String[] args) { Scanner keyboard= new Scanner(System.in); int Mean = 0; double SD= 0.0; int Count= 0; System.out.print("How many numbers will you be entering? "); int NumAmount = keyboard.nextInt(); System.out.println("Thank you. Please enter the " + NumAmount + " values below:"); GetNumbers(NumAmount); int ListNum= GetNumbers(NumAmount); double [] values = new double [NumAmount]; StanDev(values, NumAmount); System.out.println("Statistics for the given numbers:"); } static int GetNumbers(int NumAmount) { for (int n =0; n<=NumAmount;n++) { int [] values = new int [NumAmount]; Scanner keyboard= new Scanner(System.in); int numbers = keyboard.nextInt(); System.out.println(numbers); values [n]=numbers; } static double StanDev(double values,int NumAmount) { for(int i = 0; i < NumAmount; i++) { sum += values[i]; double mean = sum / NumAmount; double sq_diff_sum = 0; } for(int i = 0; i <NumAmount ; ++i) { double diff = values[i] - mean; sq_diff_sum += diff * diff; } double deviance= sq_diff_sum / n; return sqrt(deviance); } } }
- 05-29-2008, 02:48 AM #2
Please check those braces that were not paired....
specially at GetNumbers() and StanDev() method....freedom exists in the world of ideas
- 05-29-2008, 03:17 AM #3
Java doesn't allow also to compile a method inside a method.
freedom exists in the world of ideas
- 05-29-2008, 04:09 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
And also you have used some members without declaring. Careful about adding parenthesis in the code. That's the major issue you have comes with.
Similar Threads
-
Sun Java Platform, Standard Edition 6u6
By Java Tip in forum Java SoftwareReplies: 0Last Post: 04-26-2008, 08:26 PM -
Sun Java Platform, Standard Edition 6u3
By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-04-2007, 09:10 PM -
Sun Java Platform, Standard Edition 6u2
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-08-2007, 05:45 PM


LinkBack URL
About LinkBacks

Bookmarks