I have a code and its almost done. Its for a school project and I am stuck. I have DivSales and a CorporateSales.cpp. The programs should ask the user for 6 divisions quarterly sales. Display the results into a table and give a total of sales. My total feature is not working through my class. Hre is the code:
DivSales.h:
#ifndef DIVSALES_H
#define DIVSALES_H
#include <iostream>
//DivSales class delcaration
class DivSales
{
private:
static double totalSales; //static member variable for total sales
double quarters[4]; //variable to hold quarters
public:
//Mutator function to hold quarter sales and get totalSales for each quarter
void Q(double q0, double q1, double q2, double q3)
{
quarters[0]=q0;
quarters[1]=q1;
quarters[2]=q2;
quarters[3]=q3;
totalSales =+ q0+q1+q2+q3;
}
//accessor function to get quarters
double numQuarters(int quart)
{ return quarters[quart]; }
//accessor function to get total sales for all quarters
double getTotalSales()
{ return totalSales; }
};
#endif
CorporateSales.cpp:
#include <iostream>
#include <iomanip>
#include "DivSales.h"
using namespace std;
//get function from DivSales class
void Q(double, double, double, double);
double numQuarters(int); //call from DivSale
double getTotalSales(); //call from DivSale
//link to total sales in DivSales Class Header file
double DivSales::totalSales;
int main () {
DivSales div[6]; //variable to hold 6 Divisions
double quarter[4]; //varialbe to hold 4 quarters
//for loop to prompt for 6 divisions 4 quarters sales
cout << "PLEASE ENTER SALES FOR EACH DIVISION'S 4 QUARTERS" << endl;
for(int count1=0; count1 < 6; count1++)
{
//request for Division office sales
cout << " " << endl;
cout << "Please enter the sales for Division " << (count1 + 1) << ": " << endl;
cout << " " << endl;
//loop for sales input per quarter
for (int i=0; i < 4; i++)
{
cout << "Quarter " << (i +1) << " Sales: ";
cin >> quarter[i];
//validate input for sales is greater than 0
while (quarter[i] < 0)
{
cout << "Please enter a number greater than or equal to 0: ";
cin >> quarter[i];
}
}
//storing numbers into div array for future calling
div[count1].Q(quarter[0], quarter[1], quarter[2], quarter[3]);
}
//display results with formatting
cout << fixed << showpoint << setprecision(2);
//giving results
cout << "\nHere are the total sales for the company\n";
cout << " " << endl;
cout << "----------------------------------------------------------------------\n";
//for loop to give division and quarter sales table
for (int count = 0; count < 6; count++)
{
//list division
cout << "Division " << (count + 1) << ": " << endl;
//list 4 quarters of sales
for (int test= 0; test < 4; test++)
{
cout << "\tQuarter " << (test + 1) << ": $" << div[count].numQuarters(test) << endl;
}
}
cout << "" << endl; //spacer
//list total sales from DivSales class function
cout << "\t\tTotal Sales for Company: \t$ " << div[0].getTotalSales() << endl;
cout << "----------------------------------------------------------------------\n";
cin.ignore();
cin.get();
return 0;
}
any help would be GREAT. Thak you in advance as always.