Advertisement
NewbProgrammer

WholeCode

Dec 17th, 2012
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.94 KB | None | 0 0
  1. #include<iostream>
  2. #include<cstdlib>
  3. #include<fstream>
  4.  
  5. using namespace std;
  6.  
  7. const int SIZE = 12;
  8.  
  9. struct Division
  10. {
  11.       char divName[SIZE]; // Division name
  12.       double sales[4]; // Quarterly sales stored as an array
  13. };
  14.          
  15.  
  16.  
  17. int main()
  18. {
  19.        void Intro();
  20.        Division CreateCorporateFile();
  21.        Division DisplayCorporateSales();
  22.        
  23.        Intro();
  24.        CreateCorporateFile();
  25.        DisplayCorporateSales();
  26.        
  27.        
  28.        system("PAUSE");
  29.        return 0;
  30. }
  31.  
  32. void Intro()
  33. {
  34.      cout<<"This program will prompt you to enter in quarterly sales for "
  35.            "four different\ndivisions of a company.\n\n";
  36. }
  37.  
  38.  
  39. Division CreateCorporateFile()
  40. {
  41.      Division div;
  42.      
  43.      for(int i = 0; i < 4; i++)
  44.      {
  45.              int quarter = 1;
  46.              cout << "Enter the name of the division: ";
  47.              cin >> div.divName[i];
  48.              for(int i = 0; i < 4; i++)
  49.              {
  50.                   cout << "Enter in the sales for quarter "<< quarter <<": ";
  51.                   cin >> div.sales[i];
  52.                   if(div.sales[i] > 0)
  53.                   {
  54.                        quarter++;
  55.                   }
  56.                   else
  57.                   {
  58.                        cout << "Sales are not allowed to be negative.\n";
  59.                   }
  60.              }
  61.      }
  62.      
  63.      return div;
  64. }
  65.  
  66.  
  67. Division DisplayCorporateSales()
  68. {
  69.          Division test;
  70.          
  71.          Division CreateCorporateFile();
  72.          
  73.          test = CreateCorporateFile();
  74.          
  75.          for(int i = 0; i < 4; i++)
  76.          {
  77.              cout << "Here are the quarterly sales for " << test.divName[i]
  78.               << ": ";
  79.              for(int i = 0, quarter = 1; i < 4; ++i, ++quarter)
  80.              {
  81.                   cout << "Quarter "<< quarter << " sales: $"<< test.sales[i]
  82.                    <<"\n";
  83.              }
  84.          }
  85.          
  86.          return test;
  87.  
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement