Question: Write a JAVA program that prints the running average, displayed to 2 decimal places, of k values at a time from a list of numbers.
Write a JAVA program that prints the running average, displayed to 2 decimal places, of k values at a time from a list of numbers. Input validation is not required. See how this works below. Remember to include everything that is needed such as imports, classes, and the main method.
Assume the list of numbers is in variable list and the user enters a number for variable k. If k = 3 then the program should print the average of the values in list[0], list[1], list[2], then the average of the values in list[1], list[2], list[3], then the average of the values in list[2], list[3], list[4], and so on.
Hint: Use printf("%.2f", num) to display a number to 2 decimal places.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
