September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -1,14 +1,14 @@
|
|||
public class RMS {
|
||||
public static double rms(double[] nums){
|
||||
double ms = 0;
|
||||
for (int i = 0; i < nums.length; i++)
|
||||
ms += nums[i] * nums[i];
|
||||
ms /= nums.length;
|
||||
return Math.sqrt(ms);
|
||||
public class RootMeanSquare {
|
||||
|
||||
public static double rootMeanSquare(double... nums) {
|
||||
double sum = 0.0;
|
||||
for (double num : nums)
|
||||
sum += num * num;
|
||||
return Math.sqrt(sum / nums.length);
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
public static void main(String[] args) {
|
||||
double[] nums = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0};
|
||||
System.out.println("The RMS of the numbers from 1 to 10 is " + rms(nums));
|
||||
System.out.println("The RMS of the numbers from 1 to 10 is " + rootMeanSquare(nums));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue