Question: her the code I have so far in java import java.io.File; import java.io.FileNotFoundException; import java.util.*; import java.io.*; public class forecast { //this is the main
her the code I have so far in java import java.io.File; import java.io.FileNotFoundException; import java.util.*; import java.io.*; public class forecast { //this is the main method to print the required 2 D array public static void main(String[] args) throws FileNotFoundException { String[][] read=readData(); //this will print the required data for (String[] str:read){ System.out.println(str[0]+" "+str[1]); } int numWeights; Scanner sc = new Scanner(System.in); numWeights = sc.nextInt(); List weights = new ArrayList(); sc = new Scanner(System.in); Double wts; for(int i=0;i weights, String data[][]) { int forecastspan = weights.size(); //System.out.println(data.length); // we have more weights than number of months return -999 if(weights.size()>data.length) return -999.0; Double weightedValue = 0.0; for(int i = data.length-1;i>=data.length -forecastspan; i--){ weightedValue+= Double.parseDouble(data[i][1])*weights.get(i-data.length+forecastspan); } return weightedValue; } public static String[][] readData() throws FileNotFoundException { File file=new File("Demand.txt"); //this is the readData method which is required //here we will scan the txt file Scanner scanner=new Scanner(file); scanner.nextLine(); int size=scanner.nextInt(); /ow we will store line by line content of textfile into the 2D array. String[][] demandValues=new String[size][2]; for (int i=0;i 

month demand 7 000 0 AW NP January 15 February 9 March 7 April 6 May 3 June 5 July 8 9 10 Write a MAD calculation method just as we did in class EXCEPT the method should accept two two- dimensional String arrays as arguments (one two-dimensional String array will contain the observed demand read from Demand.txt and the other two-dimensional String array will contain forecasted demand values). Both methods still should return a double. Note that this question should require a basic modification to the code we wrote in class MAD. month demand 7 000 0 AW NP January 15 February 9 March 7 April 6 May 3 June 5 July 8 9 10 Write a MAD calculation method just as we did in class EXCEPT the method should accept two two- dimensional String arrays as arguments (one two-dimensional String array will contain the observed demand read from Demand.txt and the other two-dimensional String array will contain forecasted demand values). Both methods still should return a double. Note that this question should require a basic modification to the code we wrote in class MAD Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
