Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<fstream>
- #include<sstream>
- #include <vector>
- using namespace std;
- const int SIZE = 12;
- struct Division
- {
- char divName[SIZE]; // Division name
- double sales[4]; // Quarterly sales stored as an array
- };
- int main()
- {
- void Intro();
- std::vector<Division> CreateCorporateFile();
- void DisplayCorporateSales();
- Intro();
- DisplayCorporateSales();
- system("PAUSE");
- return 0;
- }
- void Intro()
- {
- cout<<"This program will prompt you to enter in quarterly sales for "
- "four different\ndivisions of a company.\n\n";
- }
- std::vector<Division> CreateCorporateFile()
- {
- std::vector<Division> divArray;
- Division div;
- int x = 0;
- for(int x = 0; x < 4; x++)
- {
- /*do {*/int quarter = 1;
- cout << "Enter the name of the division: ";
- cin >> div.divName;
- for(int i = 0; i < 4; i++)
- {
- cout << "Enter in the sales for quarter "<< quarter <<": ";
- cin >> div.sales[i];
- if(div.sales[i] > 0)
- {
- quarter++;
- }
- else
- {
- cout << "Sales are not allowed to be negative.\n";
- }
- }
- divArray.push_back(div);
- /*x++;
- } while(x < 4);*/
- }
- return divArray;
- }
- void DisplayCorporateSales()
- {
- Division div;
- std::vector<Division> divisions = CreateCorporateFile();
- for (size_t i=0; i<divisions.size(); i++)
- {
- cout << "Here are the quarterly sales for " << divisions[i].divName
- << ": \n";
- Division div = divisions[i];
- for(int j = 0, quarter = 1; j < 4; ++j, ++quarter)
- {
- cout << "Quarter "<< quarter << " sales: $"<< div.sales[j]
- <<"\n";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement