Answer to Question #306872 in C for MANISH kumar

Question #306872

total sales a company has four sales people who sell 5 different products. once a day, each salesperson passes in a slip for each different type of product sold. each slip contains a) salesperson id b) product number c) total price (in rs.) of that product sold that day assume that all slip data are stored in a file. write a program that can be used by every salesperson to store his/her data in the file. write another program to generate weekly summary report on every saturday night in a tabular format. report will display (based on user’s choice) a) product-wise daily sale b) salesperson-wise daily sale c) maximum and minimum sale (product and salesperson-wise) d) total summary of weekly sales

1
Expert's answer
2022-03-07T07:11:13-0500
#include <iostream>

using ​namespace std;

int main()
{
    const int salespeoples{ 4 };
    const int products{ 5 };
    double sales[salespeoples][products]{ 0 };
    int salespeopl;
    int prod;
    float sale;
    // Getting data per day
    for (int i = 0; i < salespeoples * products; i++) 
    {
        cout << "Enter the seller number 1 ... 4 ";
        cin >> salespeopl;
        cout << "Enter product number 1 ... 5 ";
        cin >> prod;
        cout << "Enter the sale amount ";
        cin >> sale;
        // We take into account the fact the numbering of
        // arrays starts from zero
        sales[salespeopl - 1][prod - 1] += sale;
    }
    cout << "Total sale:" << "\n";
    for (int i = 0; i < products; i++) 
    {
        sale = 0;
        for (int j = 0; j < salespeoples; j++) 
        {
            sale += sales[j][i];
        }
        cout <<"Product " << i + 1 << " sales amount: "<<sale << "\n";
    }

    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS