using namespace std;
int const LOCATION_DIM_SZ = 2;
int const TIME_DIM_SZ = 2;
int const PRODUCT_DIM_SIZE = 3;
string Location[] = { "FL", "TX" };
string Period[] = { "Jan", "FEB" };
string Product[] = { "iPhone","iPad","MacBookPro" };
/*1*/
void printSalesPerProductPerLocation(double sales[LOCATION_DIM_SZ][TIME_DIM_SZ][PRODUCT_DIM_SIZE]) {
int i(0), j(0), k(0);
double salesPerProductPerLocation = 0;
cout < "total="" sales="" per="" product="" per="" location"=""><>
cout < "="===================================""><>
for (i = 0; i < 3;="" i++)="">
for (j = 0; j < 2;="" j++)="">
for (k = 0; k < 2;="" k++)="">
salesPerProductPerLocation += sales[i][k][j];
cout < "total="" sales="" for="" "="">< product[i]="">< "="" in="" "="">< location[k]="">< "="$"">< salesperproductperlocation="">< "="" millions"=""><>
}
}
}
cout <>
cout < "="==================================================""><>
}
int main(int argc, const char* argv[]) {
double sales[LOCATION_DIM_SZ][TIME_DIM_SZ][PRODUCT_DIM_SIZE] = { 0 };
sales[0][0][0] = 45;
sales[0][0][1] = 8;
sales[0][0][2] = 4;
sales[0][1][0] = 35;
sales[0][1][1] = 10;
sales[0][1][2] = 5;
sales[1][0][0] = 75;
sales[1][0][1] = 15;
sales[1][0][2] = 13;
sales[1][1][0] = 45;
sales[1][1][1] = 17;
sales[1][1][2] = 23.1;
printSalesPerProductPerLocation(sales);
return 0;
}
DESIRED OUTPUT:
Total Sales per Product per Location
====================================
Total Sales for iPhone in FL =$ 80.00 millions
Total Sales for iPhone in TX =$ 120.00 millions
Total Sales for iPad in FL =$ 18.00 millions
Total Sales for iPad in TX =$ 32.00 millions
Total Sales for MacBookPro in FL =$ 9.00 millions
Total Sales for MacBookPro in TX =$ 36.10 millions