Answer to Question #187794 in C++ for Nabrass Gull

Question #187794

Pakistan online Daraz company has four agent (1 to 4) who sell 5 different products ( 1 to 5). Once per day, each agent passes in a slip for each different type of product sold. Every agent passes in between 0 to 5 slips each day. Each slip has the following information on it:

•       The agent number

•       The product number 

•       Total rupees of that product sold that day. 

Write a program in C++ that will read all this information for last month’s sales and brief the total sales by agent by product. The output should be in tabular form. 


1
Expert's answer
2021-05-01T15:36:54-0400
#include<bits/stdc++.h>
using namespace std;
class Slip
{
public:
    int agent_no,products;
    float sale_rs;
};
int main()
{
    int n,i;
    float total1=0,total2=0,total3=0,total4=0;
    cout<<"Enter the number of slips ";
    cin>>n;
    Slip s[n];
    for(i=0;i<n;i++)
    {
        cout<<"\nEnter Agent number ";
        cin>>s[i].agent_no;
        cout<<"\nEnter product number ";
        cin>>s[i].products;
        cout<<"\nEnter rupees of product sold ";
        cin>>s[i].sale_rs;
    }
    for(i=0;i<n;i++)
    {
        if(s[i].agent_no==1)
        {
            total1=s[i].sale_rs+total1;
        }
        if(s[i].agent_no==2)
        {
            total2=s[i].sale_rs+total2;
        }
        if(s[i].agent_no==3)
        {
            total3=s[i].sale_rs+total3;
        }
        if(s[i].agent_no==4)
        {
            total4=s[i].sale_rs+total4;
        }
    }
    cout<<"\n\n\t ********** Displaying Last Month Sales ********** \n\n"<<" ";
    cout<<"\n\tAgent Number"<<"\t\tTotal Rupees of product sold";
    cout<<"\n\t------------------------------------------------";
    cout<<"\n\t "<<"1. "<<"\t\t\t "<<total1;
    cout<<"\n\t "<<"2. "<<"\t\t\t "<<total2;
    cout<<"\n\t "<<"3. "<<"\t\t\t "<<total3;
    cout<<"\n\t "<<"4. "<<"\t\t\t "<<total4;
}

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