C++ Programming: I need help writing a void function that prints sales details using 3 for loops. Please see my code below ... not sure how to write the function. But this is what i've got so far. Please leave main alone. What the output should look like is posted below the code. Thanks :)  #include #include #include 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 printSalesDetails(double sales[LOCATION_DIM_SZ][TIME_DIM_SZ][PRODUCT_DIM_SIZE]) { int i(0), j(0), k(0); int sum = 0; cout << "Sales Details per Location per Period per Product" << endl; cout << "=================================================" << endl; for (i = 0; i < 2; i++){ double salesPerLocation = 0; sum = 0; for (j = 0; j < 2; j++){ double salesPerPeriod = 0; for (k = 0; k < 3; k++){ double salesPerProduct = 0; sum += sales[i][k][j]; } } cout << "Sales for location " << Location[i] << '\\' << Period[i] << '\\' << Product[i] << "\t=$" << sum << endl; } cout << "===================================================" << endl; } 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; printSalesDetails(sales); return 0; } DESIRED OUTPUT: Sales Details per Location per Period per Product ================================================sales for Location FL/Jan/iPhone =$ 45.00 millions sales for Location FL/Jan/iPad =$ 8.00 millions sales for Location FL/Jan/MacBookPro =$ 4.00 millions sales for Location FL/FEB/iPhone =$ 35.00 millions sales for Location FL/FEB/iPad =$ 10.00 millions sales for Location FL/FEB/MacBookPro =$ 5.00 millions sales for Location TX/Jan/iPhone =$ 75.00 millions sales for Location TX/Jan/iPad =$ 15.00 millions sales for Location TX/Jan/MacBookPro =$ 13.00 millions sales for Location TX/FEB/iPhone =$ 45.00 millions  sales for Location TX/FEB/iPad =$ 17.00 millions sales for Location TX/FEB/MacBookPro =$ 23.10 millions Sum of Sales for all Apple =$ 295 millions

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%

C++ Programming:

I need help writing a void function that prints sales details using 3 for loops. Please see my code below ... not sure how to write the function. But this is what i've got so far. Please leave main alone. What the output should look like is posted below the code. Thanks :) 

#include <iostream>
#include <string>
#include <iomanip>

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 printSalesDetails(double sales[LOCATION_DIM_SZ][TIME_DIM_SZ][PRODUCT_DIM_SIZE]) {

int i(0), j(0), k(0);
int sum = 0;

cout << "Sales Details per Location per Period per Product" << endl;
cout << "=================================================" << endl;
for (i = 0; i < 2; i++){
double salesPerLocation = 0;
sum = 0;
for (j = 0; j < 2; j++){
double salesPerPeriod = 0;
for (k = 0; k < 3; k++){
double salesPerProduct = 0;
sum += sales[i][k][j];
}
}
cout << "Sales for location " << Location[i] << '\\' << Period[i] << '\\' << Product[i] << "\t=$" << sum << endl;
}

cout << "===================================================" << endl;


}

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;


printSalesDetails(sales);

return 0;

}

DESIRED OUTPUT:

Sales Details per Location per Period per Product ================================================sales for Location FL/Jan/iPhone =$ 45.00 millions

sales for Location FL/Jan/iPad =$ 8.00 millions

sales for Location FL/Jan/MacBookPro =$ 4.00 millions

sales for Location FL/FEB/iPhone =$ 35.00 millions

sales for Location FL/FEB/iPad =$ 10.00 millions

sales for Location FL/FEB/MacBookPro =$ 5.00 millions

sales for Location TX/Jan/iPhone =$ 75.00 millions

sales for Location TX/Jan/iPad =$ 15.00 millions

sales for Location TX/Jan/MacBookPro =$ 13.00 millions

sales for Location TX/FEB/iPhone =$ 45.00 millions 

sales for Location TX/FEB/iPad =$ 17.00 millions

sales for Location TX/FEB/MacBookPro =$ 23.10 millions

Sum of Sales for all Apple =$ 295 millions

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education