Question: here what 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
here what 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 
Write a public static method called exponentialSmoothing Forecast that determines a forecast using the ex- ponential smoothing forecasting method. The method should be constructed according to the following instructions: a. Method accepts a double argument called alpha. b. The method accepts a two-dimensional String array argument called demand. Note that the values in the first column of this array are months and the values in the second column are the prior demand values. c. The method returns a two-dimension String array that contains the forecast determined using the exponential smoothing average method in the second column of the array and the month associated with each forecasted value in the first column. The forecast value for any period where a forecast cannot be calculated should be specified to be -999. The name of the month in the last period of your forecast should be specified as Next period. 1 - CN 4. 5 month demand 7 January 15 February 9 March 7 April 6 May 3 June 5 July 8 6. 7. 8. 9 10 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
