In this question you will create a method in Forecasting.java named readData that reads the data from Demand.txt located in the input_files directory. a. Create a static method in Forecasting.java named readData with the following signature specifications: • access: public • return type: two-dimensional String array • arguments: none b. In the readData method, create a two-dimensional array named demandValues that stores String values. The first row of Demand.txt contains column headers. readData should read those values in, but disregard (do nothing) with them. The second row in Demand.txt contains the number of periods of prior demand included in the file. That value should be read and used to size the first dimension of demandValues. The second dimension of demandValues should be specified so that both the month and the demand value can be stored in separate columns. c. Add additional code to readData that reads the month/demand values from Demand.txt and stores them in demandValues. d. Return demandValues. Question 2 Write a public static method called weightedMovingAverageForecast that determines a forecast using the weighted moving average forecasting method. The method should be constructed according to the following instructions: a. The method accepts a single-dimension double array argument called weights argument. weights consists of values between 0 and 1. The sum of all values in weights must be 1. 1 b. The method also 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-dimensional String array that contains the forecast determined using the weighted moving 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”. This resource contains a simple description of the weighted moving average method. https:// denninginstitute.com/modules/dau/stat/mvavgs/wma_frm.html Question 3 Write a public static method called exponentialSmoothingForecast that determines a forecast using the exponential 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”. 2 Question 4 Write a MAD calculation method just as we did in class EXCEPT the method should accept two twodimensional 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. Question 5 Add code to the main method that accomplisheds the following: a. Fills the String array named di declared for you by calling the readData method created in Question 1. b. Generates a forecast using the weightedMovingAverageForecast method using weights = {.25, .75}. Print that forecast to the screen using the printForecast method provided. Determine the MAD for this forecast using the method implemented in Question 4. Print this value to the screen with a label stating what it represents. c. Generates a forecast with the exponentialSmoothingForecast method using α = .4. Print that forecast to the screen using the printForecast method provided. Determine the MAD for this forecast using the method implemented in Question 4. Print this value to the screen with a label stating what it represents.
This is for java
Question 1
In this question you will create a method in Forecasting.java named readData that reads the data from
Demand.txt located in the input_files directory.
a. Create a static method in Forecasting.java named readData with the following signature specifications:
• access: public
• return type: two-dimensional String array
• arguments: none
b. In the readData method, create a two-dimensional array named demandValues that stores String values.
The first row of Demand.txt contains column headers. readData should read those values in, but
disregard (do nothing) with them. The second row in Demand.txt contains the number of periods of
prior demand included in the file. That value should be read and used to size the first dimension of
demandValues. The second dimension of demandValues should be specified so that both the month
and the demand value can be stored in separate columns.
c. Add additional code to readData that reads the month/demand values from Demand.txt and stores
them in demandValues.
d. Return demandValues.
Question 2
Write a public static method called weightedMovingAverageForecast that determines a forecast using the
weighted moving average forecasting method. The method should be constructed according to the following
instructions:
a. The method accepts a single-dimension double array argument called weights argument. weights consists of values between 0 and 1. The sum of all values in weights must be 1.
1
b. The method also 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-dimensional String array that contains the forecast determined using the
weighted moving 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”.
This resource contains a simple description of the weighted moving average method. https://
denninginstitute.com/modules/dau/stat/mvavgs/wma_frm.html
Question 3
Write a public static method called exponentialSmoothingForecast that determines a forecast using the exponential 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”.
2
Question 4
Write a MAD calculation method just as we did in class EXCEPT the method should accept two twodimensional 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.
Question 5
Add code to the main method that accomplisheds the following:
a. Fills the String array named di declared for you by calling the readData method created in Question
1.
b. Generates a forecast using the weightedMovingAverageForecast method using weights = {.25, .75}.
Print that forecast to the screen using the printForecast method provided. Determine the MAD for
this forecast using the method implemented in Question 4. Print this value to the screen with a label
stating what it represents.
c. Generates a forecast with the exponentialSmoothingForecast method using α = .4. Print that forecast
to the screen using the printForecast method provided. Determine the MAD for this forecast using
the method implemented in Question 4. Print this value to the screen with a label stating what it
represents.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 5 images