Use Rectangular array to solve this problem. A company has 3 sales people (1-3)
ID: 3538684 • Letter: U
Question
Use Rectangular array to solve this problem.
A company has 3 sales people (1-3) who sells 5 different products (1-5).
Write a program that will read all the information for last month%u2019s sales and summarize the total sales by each sales person and by each product. The monthly sales is stored in a rectangular array sales [3,5] with each row represents a sales person and each column represents a product. Display the tabular array with sales for each sales person and each product and the total sales for each sales person and each product.
Explanation / Answer
#include // used for cin, cout #include #include #include using namespace std; // Global Type Declarations // Function Prototypes void instruct (void); void pause (); //Global Variables - should not be used without good reason. int main () { // Declaration section const int EMPLOYEE = 5, PRODUCTS = 6; double sales[ EMPLOYEE ][ PRODUCTS ] = { 0.0 }, value, totalSales, productSales[ PRODUCTS ] = { 0.0 }, grandTotal = 0; int salesPerson, product; ifstream inDataFile ("A:/datafile.txt", ios::in ); // Executable section instruct (); { if ( !inDataFile ) { cerr > product; inDataFile >> value; sales[ salesPerson ][ product ] += value; inDataFile >> salesPerson; } coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.