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!