Hello!

Here's what I wanted to do:

Create an array with four elements holding the total corporate sales for the division.
-Create a private static variable for holding the total corporate sales for all divisions for the entire year.
-A member function that takes four arguments, each assumed to be the sales for a quarter
-The value of the arguments should be copied into the array that holds the sales data.
-The total of the four arguments should be added to the static variable that holds the total yearly corporate sales.
-A function that takes an integer argument within the range of 0 to 3. The argument is to be used as a subscript into the division quarterly sales array. The function should return the value of the array element with that script.
***Input validation: Do not accept negative numbers for any values.

Here's what I have so far:

#include <iomanip>
# include <cmath>
#include <iostream>
using namespace std;

// Function Prototypes

void pause(void);


class DivSales
{

private:
static float corpSales;
float divSales;

public:
DivSales() {divSales = 0;}
void addDivSales (float s)
{ divSales += s; corpSales += divSales;}
float getDivisionSales () {return divSales;}
float getCorpSales () { return corpSales;}
};


// float DivSales::corpSales = 0;

int main ()

{

//float DivSales::corpSales = 0;
static float corpSales = 0;

DivSales divisions[4];

int count;

for (int count = 0; count < 4; count ++)
{
float sal;

cout << "Enter the sales for each division ";
cout << (count + 1) << " : ";
cin >> sal;
divisions[count].addDivSales(sal);

}

cout << setprecision(2);
cout << showpoint << fixed;
cout << "\nHere are the division sales: \n";

for (count = 0; count < 4; count++)
{
cout << "Division " << (count + 1) << " $ ";
cout << divisions[count].getDivisionSales() << endl;

}

cout << "Total corporate sales:\t$ ";
cout << divisions[0].getCorpSales() << endl;

return 0;


} 

// pause


void pause(void)
  {
  cout << "\n\n";
  system("PAUSE");
  cout << "\n\n";
  return;
  }

However, I have not added each of the quarterly sales , I don't know how to do that.
Thanks a lot in advance!

First welcome the board and thanks for using code tags, but I think you might have used the wrong ones and it mangled your indentation----at least I hope that explains the lack of indentation.

Second, the way I read the instructions is to do something like this;

class Division
{
     static totalCompanySales;
     quarterlySales[4];

    public:
     setQuarterlySalesData(a, b, c, d)
     {
        //validate a, b, c, d are not negative here
        //if a, b, c, d are valid then assign to quaterlySales here
        //add a, b, c, d to companySales here
      }
       getQaurterlySales(i){return quarterlySales[i];}
};

Then again, I don't have the full instructions. However, using this approach a company could be described as an array of Divisions. Company quarterly sales could then be determined by getting each divisions sales for a given quarter using the get function, whereas the total yearly company sales is kept in the static variable.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.