Is this correct? I wrote a decimal format and it doesn't work. how do i correct this:
return sum / myFormatter.format(Math.sqrt(x.length - 1));
I will submit the full code if needed.
Is this correct? I wrote a decimal format and it doesn't work. how do i correct this:
return sum / myFormatter.format(Math.sqrt(x.length - 1));
I will submit the full code if needed.
OK, I'll assume that the myFormatter
variable holds an instance of the DecimalFormat
class. And that the sum
variable is some kind of number -- like a int or double or something similar.
So the line you gave above doesn't compile -- because the result of the ".format(...)
" method is a String value, and you can't do math (like the division ('/') operator) on String values.
Maybe this is what you want...?
return myFormatter.format(sum / Math.sqrt(x.length - 1));
@JeffGrigg
This also won't compile as this will return String and the function returns double.
I've given answer in above thread:
http://www.daniweb.com/software-development/java/threads/469961/mean-standard-deviation
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.