1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
|
#include <iostream>
#include <string>
using namespace std;
struct CorpData
{
string division;
double first,
second,
third,
fourth,
total,
average;
CorpData (string d = "unknown", double fi = 0, double se = 0,
double th = 0, double fo = 0, double tot = 0, double avg = 0)
{
division = d;
first = fi;
second = se;
third = th;
fourth = fo;
total = tot;
average = avg;
}
};
void getSales(CorpData &);
void setSales(const CorpData &);
int main(void)
{
CorpData north, south, east, west;
getSales(north);
getSales(south);
getSales(east);
getSales(west);
cout << " " << endl;
setSales(north);
cout << " " << endl;
setSales(south);
cout << " " << endl;
setSales(east);
cout << " " << endl;
setSales(west);
return 0;
}
void getSales(CorpData &sales)
{
cout << "Enter the sales data for each division\n" << endl;
cout << "Division: ";
cin.get();
getline(cin, sales.division);
cout << "First Quarter Sales: ";
cin >> sales.first;
cout << "Second Quarter Sales: ";
cin >> sales.second;
cout << "Third Quarter Sales: ";
cin >> sales.third;
cout << "Fourth Quarter Sales: ";
cin >> sales.fourth;
}
void setSales(const CorpData &sales)
{
cin.clear();
cin.ignore(INT_MAX, '\n');
cout << "Divison: " << sales.division << endl;
cout << "Average Sales: " << ((sales.first + sales.second + sales.third +
sales.fourth) / 4) << endl;
cout << "Total Sales: " << (sales.first + sales.second + sales.third +
sales.fourth) << endl;
}
|