Advertisement
NewbProgrammer

Attempt

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