#include #include #include using namespace std; struct CorpData //Holds data { string divisionName; double firstQtr; double secondQtr; double thirdQtr; double fourthQtr; double totalAnnual; double averageQtr; }; void getItems(CorpData&);//entire CorpData structure is being passed to getItems function //it is passed by reference so that getItems cans place new data //into the original structure variable void showItems(CorpData);//entire CorpData structure is being passed to showItems function //it is passed by value because showItems just needs to copy data //and does not need to modify original structure variable. int main() { CorpData east;//defines variable part to be a CorpData structure CorpData west;//defines variable part to be a CorpData structure CorpData north;//defines variable part to be a CorpData structure CorpData south;//defines variable part to be a CorpData structure cout << endl; cout << "Enter the following information about the East Division\n"; getItems(east);//get data for east cout << endl; cout << "Enter the following information about the West Division\n"; getItems(west);//get data for west cout << endl; cout << "Enter the following information about the North Division\n"; getItems(north);//get data for north cout << endl; cout << "Enter the following information about the South Division\n"; getItems(south);//get data for south cout << endl; cout << "***********************************\n"; cout << "East Division\n"; showItems(east);//show items for east cout << "***********************************\n"; cout << endl; cout << "***********************************\n"; cout << "West Division\n"; showItems(west);//show items for west cout << "***********************************\n"; cout << endl; cout << "***********************************\n"; cout << "North Division\n"; showItems(north);//show items for north cout << "***********************************\n"; cout << endl; cout << "***********************************\n"; cout << "South Division\n";//show items for south showItems(south); cout << "***********************************\n"; return 0; } //================================================================================ //getItems: function stores the data input by the user in the members of CorpData //structure variable passed to the function by reference //================================================================================ void getItems(CorpData &sales) { cout << "Enter 1st quarter sales: $"; cin >> sales.firstQtr; cout << "Enter 2nd quarter sales: $"; cin >> sales.secondQtr; cout << "Enter 3rd quarter sales: $"; cin >> sales.thirdQtr; cout << "Enter 4th quarter sales: $"; cin >> sales.fourthQtr; } //================================================================================ //showItems: function displays the data stored in the members of CorpData //structure variable passed to it //================================================================================ void showItems(CorpData sales) { sales.totalAnnual=(sales.firstQtr+sales.secondQtr+sales.thirdQtr+sales.fourthQtr); sales.averageQtr=((sales.firstQtr+sales.secondQtr+sales.thirdQtr+sales.fourthQtr)/4); cout << "Total Sales: $" << fixed << setprecision(2) << sales.totalAnnual << endl; cout << "Quarterly Average Sales: $" << fixed << setprecision(2) << sales.averageQtr << endl; }