Complete the following Java method. The purpose of the method is to modify the input array of doubles so that each number in the array is rounded to the nearest integer. It also creates and returns a new array of doubles that have all the (rounded) numbers in nums that are greater than bound. Note that the returned array may not be the same size as the input array. Also, note that the numbers in the input array might be negative. You must use one or more for loops. You are NOT allowed to use the Math class.
public static double[] round(double[] nums, double bound){
public static double[] round(double[] nums, double bound) {
int count = 0;
for(int i = 0; i < nums.length; i++) {
if(Double.valueOf(String.format("%.0f", nums[i])) > bound) {
count++;
}
}
double[] result = new double[count];
int index = 0;
for(int i = 0; i < nums.length; i++) {
if(Double.valueOf(String.format("%.0f", nums[i])) > bound) {
result[index++] = Double.valueOf(String.format("%.0f", nums[i]));
}
}
return result;
}
Complete the following Java method. The purpose of the method is to modify the input array...