Question: Given that Sale[NUM_STORES][NUM_MONTHS][NUM_DEPTS] is a three dimensional array of float-point type. Write a method MonthSales to return actual sales and calculate the total value of
Given that Sale[NUM_STORES][NUM_MONTHS][NUM_DEPTS] is a three dimensional array of float-point type. Write a method MonthSales to return actual sales and calculate the total value of sales during a specific month by each department and in each store. The return type of the function is void and the function should have 2 input parameters: Sale array and the month user specified. The constants NUM_STORES, NUM_MONTHS, and NUM_DEPTS may be accessed globally by defining the following global variables:
#define NUM_DEPTS 2
#define NUM_STORES 2
#define NUM_MONTHS 12
The array Sale is initialized by the following statement in your main():
float Sale[NUM_STORES][NUM_MONTHS][NUM_DEPTS] =
{ 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0, 2.1, 2.2,
2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2,
3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2,
2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2
};
The Print method, has input parameters Sale, month, and values from MonthSales and it will print out the array in row and column format by store then the month requested and associated sales in a tabular format.
Then read in from a data file data.txt additional data scenarios for testing .. a value of -1 indicates the end of the data for that test.
Be sure to account for all the standard file checks (file doesnt exist, file empty (should always contain at least a -1)) and handle the issues of not enough or too much data for the array, a complete (right number of data values) but array contains a negative number - still print the array but print an error message.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
