package deviation;
import java.util.Scanner; 

public class Deviation { 
public static void main(String[] args) { 
Scanner input = new Scanner(System.in); 

System.out.println("Enter n: "); 
int n = input.nextInt(); 
System.out.println("Enter " + n + " numbers: "); 
double[] x = new double[n]; 
int i; 
for (i = 0; i<n; i++) {
        x[i] = input.nextDouble();
    } 

double mean = mean(x, i); 
double deviation = deviation(x, i); 

System.out.println("The mean is " + mean); 
System.out.println("The standard deviation is " + deviation); 

} 
public static double deviation(double[] x, double i) { 
double mean = mean(x, i); 
double num = 0; 
num += Math.pow(x[i] - mean, 2); 
double n;

 double den = n - 1;
double deviation = Math.sqrt((num/den)); 
return deviation; 
} 
public static double mean(double[] x, double i) { 
double sum = 0; 

for(int j=0;j<i;j++) { 
sum += x[j]; 
} 
return sum / i; 
}

} 

I am geting error(red caution mark) at line 27 and even after running it it just prompts to enter number and then says :

Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - possible loss of precision
  required: int
  found:    double
    at deviation.Deviation.deviation(Deviation.java:27)
    at deviation.Deviation.main(Deviation.java:18)
Java Result: 1

plz help ppl asap I have to submit it in a day.

anybody plz help .. just give your 5 mins to help

No time now to read the code, but...
the message is clear - you have used double where an int is required. The compiler won't allow an automatic conversion because doubles can have fractional values but ints can't.

yes thats true. but can't change it to int because values can be double also and it is actually double but still i tried to change it to int then also nothing happening.

I presume it's referring to your mean method - the second parameter isn't a data value, it's some kind of aray index or size, which therefore has to be an integer type.

will you plz look at code abovce and let me know what is supposed to be done exactly because I have tried evrything but nothing working. It would be a great help . Thank u

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.