/** Assignment 1 Question 3 * COMP 1006/1406 - Fall 2021 * * Creating a simple console view for some data */ public class A1Q3{ // used to add extra information to plot output of horizontal plot public static boolean debug = false; public static double ave(double[] data, int index, int width){ // Helper function that computes the average of // 'width' consecutive values in 'data' starting at index 'i' // That is, it returns // (data[i] + data[i+1] + ... + data[i+width-1])/width // Use as you see fit. // Try to catch some bad input cases and crash your // program if input was bad. // You are NOT required to do this in your methods yet! String bad = "Bad input to ave(): "; if( data == null ){ throw new RuntimeException(bad + "data must not be null"); }else if(index < 0 || index >= data.length){ throw new RuntimeException(bad + "index i out of range"); }else if(width == 0 || width >= data.length){ throw new RuntimeException(bad + "width is invalid"); } // first compute the sum of the width numbers double sum = 0.0; for(int j=index; j