title: Corporate Sales C++
body: <p>Me and a friend are having difficulty with this program challenge that our professor assigned us. What we are having with is are int main(). Are tutors keep pointing us to it but won't explain what is wrong. So, if you could explain and show us what we are doing wrong then it would be greatly appreciated.</p>
  
  <p>Here is the question:
  A corporation has six divisions, each responsible for sales to different geographic locations. Design a Divsales class that keeps sales data for a division, with the following members:</p>
  
  <ul>
  <li>An array with four elements for holding four quarters of sales figures for the division</li>
  <li>A private static variable for holding the total corporate sales for all divisions for the entire year.</li>
  <li>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.</li>
  <li>A function that takes an integer argument within the range of 0-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 subscript.</li>
  </ul>
  
  <p>Write a program that creates an array of six DivSales objects. The program should ask the user to enter the sales for four quarters for each division. After the data is entered, the program should display a table showing the division sales for each quarter. The program should then display the total corporate sales for the year.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;cstdlib&gt;
  #include  &lt;cctype&gt;
  
  using namespace std;
  
  class DivSales
  {
  private:
      double quarter [4];
      static double DivCorp;
  
  public:
      double display(int);
      void qutrSale();
  }
  
  void DivSales::qutrSale()
  {
      int number;
  
      for (number = 0; number &lt; 4; number++)
      {
          cout &lt;&lt; "The sales for the quarter"&lt;&lt; number+1&lt;&lt; ": ";
          cin&gt;&gt; quarter [number];
  
          DivCorp += quarter[number];
  
          while (quarter[number] &lt; 0)
          {
              cout&lt;&lt; "Error, please enter a positive sale amount: $";
              cin &gt;&gt; quarter [number];
          }
      }
  }
  
  double DivSales::display(int input)
  {
      return quarter [input];
  }
  
  int main ()
  {
      int count;
      DivSales div[5];
  
      for (count=0; count&lt;5; count++)
      {
          div [count].qutrSale();
      }
      return 0;
  }
  </code></pre>
  
  <p>Some of the errors are</p>
  
  <ul>
  <li><p>Error    1   error C2628: 'DivSales' followed by 'void' is illegal (did you forget a ';'?)   h:\school\cosc 1337.01\chapter 11 program challenge 7\chapter 11 program challenge 7\corporate sales.cpp    23</p></li>
  <li><p>Error    2   error C2556: 'DivSales DivSales::qutrSale(void)' : overloaded function differs only by return type from 'void DivSales::qutrSale(void)' h:\school\cosc 1337.01\chapter 11 program challenge 7\chapter 11 program challenge 7\corporate sales.cpp    24</p></li>
  <li><p>Error    3   error C2371: 'DivSales::qutrSale' : redefinition; different basic types h:\school\cosc 1337.01\chapter 11 program challenge 7\chapter 11 program challenge 7\corporate sales.cpp    24</p></li>
  <li><p>Error    4   error C2264: 'DivSales::qutrSale' : error in function definition or declaration; function not called    h:\school\cosc 1337.01\chapter 11 program challenge 7\chapter 11 program challenge 7\corporate sales.cpp    54</p></li>
  </ul>