Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<cstdlib>
- #include<fstream>
- #include<sstream>
- 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();
- Division CreateCorporateFile();
- Division DisplayCorporateSales();
- Intro();
- CreateCorporateFile();
- 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";
- }
- Division CreateCorporateFile()
- {
- 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";
- }
- }
- x++;
- } while(x < 4);
- return div;
- }
- Division DisplayCorporateSales()
- {
- Division test;
- Division CreateCorporateFile();
- test = CreateCorporateFile();
- for(int i = 0; i < 4; i++)
- {
- cout << "Here are the quarterly sales for " << test.divName
- << ": ";
- for(int i = 0, quarter = 1; i < 4; ++i, ++quarter)
- {
- cout << "Quarter "<< quarter << " sales: $"<< test.sales[i]
- <<"\n";
- }
- }
- return test;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement