(use two-dimensional array c++ not java) A company has four salespeople (1-4) who sell five different products (1-5).each salesperson passes in a slip for each different type of product sold. Each slip contains the following:
a) salesperson number
b) product number
c) total dollar value of that product sold that day
Thus, each salesperson passes in between 0 and 5 sales slips per day. Assume the information from the slips for last month is available. Write a program that will read all information for last month’s sales (one salesperson’s data at a time) and summarize the total sales by salesperson by product. All totals should be stored in the two-dimensional array sales. After processing all the information for last month, print the results in tabular format with each of the columns representing a salesperson and each of the rows representing a product. Cross total each row to get the total sales of each product for last month; each column to get the total sales by salesperson for last month.
class Company {
private:
double **sales;
int salesPerson;
int product;
double value;
public:
Company() {
this->sales = new double[4][5];
}
double **getSales() {
return sales;
}
void setSales(double[ **sales) {
this->sales = sales;
}
void setElements(int i, int j, double value) {
this->sales[i][j] += value;
}
int getProduct() {
return product;
}
void setProduct(int product) {
this->product = product;
}
int getSalesPerson() {
return salesPerson;
}
void setSalesPerson(int salesPerson) {
this->salesPerson = salesPerson;
}
double getValue() {
return value;
}
void setValue(double value) {
this->value = value;
}
void display() {
int i=0;
for (auto ds : sales) {
cout << ++i << "\t";
for (double d : ds) cout << d << "\t";
cout << "\n";
}
}
void total(double **sales) {
// logic
}
}
Comments
Leave a comment