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
|
#include "sales.h"
#include <string>
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;
void loadData(SalesPerson reps[], const int SIZE, int &num_reps);
void printData(SalesPerson reps[], int num_reps);
//********************************************************
int main()
{
const int SIZE = 25;
SalesPerson reps[SIZE];
int num_reps = 0;
loadData(reps, SIZE, num_reps);
printData(reps, num_reps);
return 0;
}
//********************************************************
void loadData(SalesPerson reps[], const int SIZE, int &num_reps)
{
string name,
territory;
int month,
x = 0;
double amount;
fstream inFile;
inFile.open("sales_data.txt", ios::in);
inFile >> num_reps;
while (x < num_reps)
{
getline(inFile, name);
reps[num_reps].getDataFromFile(inFile);
getline(inFile, territory);
reps[num_reps].getDataFromFile(inFile);
inFile >> month >> amount;
reps[num_reps].setSales(month, amount);
inFile.ignore();
++x;
}
inFile.close();
}
//********************************************************
void printData(SalesPerson reps[], int num_reps)
{
fstream outFile;
outFile.open("a6.txt", ios::out);
outFile << "2016 SALES REPORT" << endl;
outFile << "************************************"
<< "***************" << endl;
for (int i = 0; i < num_reps; i++)
{
reps[i].printSalesPersonInfo(outFile);
reps[i].printAnnualSales(outFile);
}
outFile.close();
}
|