C++/C++

Advertisement


Question
A company has 4 salespeople(1-4) who sell 5 products (1 to 5).Once a day,each salesperson passes in a slip for each different type of product sold.Each slip contains:

a)the salesperson number
b)the product number
c)the total dollar value of that product sold that day

Thus each salesperson passes in between 0 and 5 slips per day.Assume that the information from all the slips for last month is available.Write a program that will read all this information for last month's sale and summarize the total sales by salespersons by product.After processing all the information for last month,print the result in tabular format with each of the columns represents a particular salesperson and each rows representing a particular product.Cross total each row to get the total sales of each product for last month;cross total each column to get the total sales by salesperson for last month.

*Please help me.I have been doing this for 2 weeks bt still didnt get the solution.

Answer
Hi,

I have just created the skeleton for the program!. Here there is all the function required. You have to program in the main function creating four objects for sales person and then enter the data for one month.
Please, let me know if you have problem in understanding

#include <cstdlib>
#include <iostream>

#include <string>  


#include<fstream>
class salesperson:public product
{
     private:
         string name;
         int noofperson;
         
         
     public:
         void setnumberofsalesperson(int p );
         int getnumberofsalesperson();
         void setname(string name);
         string getname();
};
void salesperson::setnumberofsalesperson(int p)
{
    noofperson = p;
    
}
int  salesperson::getnumberofsalesperson()
{
    return noofperson;
}
void  salesperson::setname(string name)
{
     name = name;
}
string salseperson::getname()
{
      return name;
}
class product
{
 private:
         
         long ProdNO[4];
         float Prodsales[4];
         int totalproduct;
         float totalsales;
         
 public:
      salesperson(int p,float t)
      {
         for90int i=0;i <4;i++)
         {
         ProdNo[i] = 0;
         ProdSales[i] = 0;
         
         }
         
      }
      void setProductNoandsales( int P,float f)
      long getproductNo(int  p);
      float getproductsales(int p);
     // void calculatetotalnoofproduct();// if you want then you can calculate the total number of all products sold
     // void calculatetotalsales();
         
};
void product::setProductNoandsales( int P,float f)
{
    prodNo[p]  = product[p]+1;
    prodsales[p] = prodsales + f;
}
long product::getproductNo(int p)
{
   return prodNo[p];
}
float product::getproductsales(int p)
{
      retrun prodsales;
}

using namespace std;

int main(int argc, char *argv[])
{

//create the four objects of salesperson and then you can enter the rest of the information for month


// end of main
   system("PAUSE");
   return EXIT_SUCCESS;
}

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


rakshitha

Expertise

Difficult questions related to C .

Experience

C ,vc ,opc ,windows CE, ActiveX

Education/Credentials
Masters in electrical engineering

©2016 About.com. All rights reserved.