1. Write a static method called runningSum that accepts an array parameter, populated with a sequence of real numbers that are read from a file. The program outputs the running sum of the numbers followed by the maximum running sum. For example, if the array contains the following data: 3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25 your method should produce the following output: running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25 max sum = 14.5 2. Arrays a1, a2… are populated as shown; display a[i] for each calls to arr; if a[i] less than or equal to 0 display a message indicating those conditions public static void arr(int[] a) { //Add the missing loop a[i] = a[i + 1] + a[i - 1]; // display a[i] } }
1.
Write a static method called runningSum that accepts an array parameter, populated with a sequence of real numbers that are read from a file. The program outputs the running sum of the numbers followed by the maximum running sum. For example, if the array contains the following data:
3.25 4.5 -8.25 7.25 3.5 4.25 -6.5 5.25
your method should produce the following output:
running sum = 3.25 7.75 -0.5 6.75 10.25 14.5 8.0 13.25
max sum = 14.5
2.
Arrays a1, a2… are populated as shown; display a[i] for each calls to arr; if a[i] less than or equal to 0 display a message indicating those conditions
public static void arr(int[] a) {
//Add the missing loop
a[i] = a[i + 1] + a[i - 1];
// display a[i]
}
}
Trending now
This is a popular solution!
Step by step
Solved in 7 steps with 3 images