Language:EN
Pages: 3
Words: 497
Rating : ⭐⭐⭐⭐⭐
Price: $10.99
Page 1 Preview
print the total sales for each product and the ove

Sales Data Table Program Assignment Answers Needed

Your Question:

A company has three salespeople (labelled 1 to 3) who sell two different products (labelled 1 and 2). Write a program to enter the sales according to products by each salesperson. Then, summarize the total sales by printing a table that includes the total sales to the right and to the bottom of the table. As an example,

Enter sales by salesperson 1 (product1 product2): 120 135

Salesperson 2 $230.00,$100.00,$330.00

Salesperson 3 $250.00,$150.00,$400.00

Step By Step Answers with Explanation

int main() {

    // Initialize a 3x2 matrix to store sales data for three salespeople and two products

        for (int j = 0; j < 2; j++) {

            // Prompt the user to enter sales for the current salesperson and product

    // Initialize variables to store the total sales for each product and each salesperson

    double total_sales_product[2] = {0, 0};

            total_sales_product[j] += sales_data[i][j];

            total_sales_salesperson[i] += sales_data[i][j];

    // Print sales data for each salesperson along with the total

    for (int i = 0; i < 3; i++) {

    cout << "Total   $" << total_sales_product[0] << "   $" << total_sales_product[1] << "   $" << (total_sales_product[0] + total_sales_product[1]) << endl;

    return 0;

3. We declare arrays `total_sales_product` and `total_sales_salesperson` to store the total sales for each product and each salesperson, respectively.

4. We calculate the total sales by iterating through the `sales_data` array.

You are viewing 1/3rd of the document.Purchase the document to get full access instantly

Immediately available after payment
Both online and downloadable
No strings attached
How It Works
Login account
Login Your Account
Place in cart
Add to Cart
send in the money
Make payment
Document download
Download File
img

Uploaded by : Miss Sheryl Smith

PageId: ELI81AB7B3