Struct Problem Final Project

I'm having trouble getting the data into the program. when i run it, it gives a value of 0 for everything.
thanks in advance to anyone that can help me with this!

A company has six salespeople. Every month, they go on road trips to sell the
company’s product. At the end of each month, the total sales for each salesperson, together with that salesperson’s ID and the month, is recorded in a file ("sales.txt"). At the end of
each year, the manager of the company wants to see this report in this following
tabular format:

sample input file: the input sales file ("sales.txt) has the following data

12345 1892.00 0.00 494.00 322.00
32214 343.00 892.00 9023.00 0.00
23422 1395.00 1901.00 0.00 0.00
57373 893.00 892.00 8834.00 0.00
35864 2882.00 1221.00 0.00 1223.00
54654 893.00 0.00 392.00 3420.00

Sample input file: The input name file ("empNames.txt") has the following data

12345 John Smith
32214 Gilbert Hope
23422 Mary Arthur
57373 Sam Bedford
35864 Cristal Benard
54654 Jocelyn Tee

#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>

using namespace std;

const int NumberSales = 6;

struct SalesPersonRecord
{
string ID;
double saleByQuarter[4];
double totalSale;
};
void initialize(ifstream& indata, SalesPersonRecord list[], int listSize);
void getData (ifstream& infile, SalesPersonRecord list[], int listSize);
void saleByQuarter (SalesPersonRecord list[], int listSize, double totalByQuarter[]);
void totalSaleByPerson(SalesPersonRecord list[], int listSize);
void printReport(ofstream& outfile, SalesPersonRecord list[], int listSize, double saleByQuarter[]);
void maxSaleByPerson(ofstream& outData, SalesPersonRecord list[], int listSize);
void maxSaleByQuarter(ofstream& outData, double saleByQuarter[]);

int main()
{

ifstream infile;
ofstream outfile;
string inputFile;
string outputFile;
double totalSaleByQuarter[4];
SalesPersonRecord salesPersonList[NumberSales];

inputFile;
initialize(infile, salesPersonList, NumberSales);
infile.close();
infile.clear();

outputFile;
getData(infile, salesPersonList, NumberSales);
saleByQuarter(salesPersonList, NumberSales, totalSaleByQuarter);
totalSaleByPerson(salesPersonList, NumberSales);
printReport(outfile, salesPersonList, NumberSales, totalSaleByQuarter);
maxSaleByPerson(outfile, salesPersonList, NumberSales);
maxSaleByQuarter(outfile, totalSaleByQuarter);
infile.close();
outfile.close();

cout<<"\n\n- CFO"<<endl;
cout<<"November-30-2015"<<endl;

return 0;
}
void initialize(ifstream& indata, SalesPersonRecord list[], int listSize)
{
int index;
int quarter;
for (index = 0; index < listSize; index++)
{
indata >> list[index].ID;
for (quarter = 0; quarter < 4; quarter++)
list[index].saleByQuarter[quarter] = 0.0;
list[index].totalSale = 0.0;
}
}

void getData(ifstream& infile, SalesPersonRecord list[], int listSize)
{
int index;
int quarter;
string ID;
double amount;

while (!infile.eof()){
for(int i = 0; i < listSize; i++){
infile >> list[i].ID;
infile >> list[i].saleByQuarter[0];
infile >> list[i].saleByQuarter[1];
infile >> list[i].saleByQuarter[2];
infile >> list[i].saleByQuarter[3];
}
}
}
void saleByQuarter(SalesPersonRecord list[], int listSize, double totalByQuarter[])
{
int quarter;
int index;

for (quarter = 0; quarter < 4; quarter++)
totalByQuarter[quarter] = 0.0;

for (quarter = 0; quarter < 4; quarter++)
for (index = 0; index < listSize; index++)
totalByQuarter[quarter] += list[index].saleByQuarter[quarter];
} //end saleByQuarter

void totalSaleByPerson(SalesPersonRecord list[], int listSize)
{
int index;
int quarter;

for (index = 0; index < listSize; index++)
for (quarter = 0; quarter < 4; quarter++)
list[index].totalSale += list[index].saleByQuarter[quarter];
} //end totalSaleByPerson

void printReport(ofstream& outfile, SalesPersonRecord list[], int listSize, double saleByQuarter[])
{
int index;
int quarter;

cout << " Night Ya Night Prime Coffee "<<endl;
cout << "----------- Annual Sales Report - 2013 -----------"<< endl;
cout << endl;
cout << " ID QT1 QT2 QT3 QT4 Total" << endl;
cout << "___________________________________________________________" << endl;
for (index = 0; index < listSize; index++)
{
cout << list[index].ID << " ";
for (quarter = 0; quarter < 4; quarter++)
cout << setw(10)
<< list[index].saleByQuarter[quarter];
cout << setw(10) << list[index].totalSale << endl;
}
cout << "Total ";
for (quarter = 0; quarter < 4; quarter++)
cout << setw(10)<< saleByQuarter[quarter];
cout << endl << endl;
} //end printReport

void maxSaleByPerson(ofstream& outData, SalesPersonRecord list[], int listSize)
{
int maxIndex=0;
int index;
string name;

for (index = 1; index <listSize; index++)
if (list[maxIndex].totalSale <list[index].totalSale)
maxIndex = index;
cout << "Max Sale by Sales Person:"<<endl;
cout << "\nSales Person Name: "<<endl;
cout << "Sales Person ID = "<< list[maxIndex].ID
<< ",\t\tAmount = $" << list[maxIndex].totalSale
<< endl;
} //end maxSaleByPerson

void maxSaleByQuarter(ofstream& outData, double saleByQuarter[])
{
int quarter;
int maxIndex = 0;

for (quarter = 0; quarter < 4; quarter++)
if (saleByQuarter[maxIndex] < saleByQuarter[quarter])
maxIndex = quarter;

cout << "\n\nMax Sale by Quarter:"<<endl;
cout << "\nQuarter = "<< maxIndex + 1
<< ",\t\tAmount = $" << saleByQuarter[maxIndex]<< endl;
}
Edit & Run


SAMPLE RUN

–––––––––––– Annual Sales Report ––––––––––––
ID QT1 QT2 QT3 QT4 Total
12345 1892.00 0.00 494.00 322.00 2708.00
32214 343.00 892.00 9023.00 0.00 10258.00
23422 1395.00 1901.00 0.00 0.00 3296.00
57373 893.00 892.00 8834.00 0.00 10619.00
35864 2882.00 1221.00 0.00 1223.00 5326.00
54654 893.00 0.00 392.00 3420.00 4705.00
Total 8298.00 4906.00 18743.00 4965.00

Max Sale by Sales Person:

Sales Person Name:XXXXXX
Sales Person ID =XXXXX , Amount = $XXXXX


Max Sale by Quarter:X

Quarter = X, Amount = $XXXX
Don't double post, it just wastes times - http://www.cplusplus.com/forum/beginner/179954/
Topic archived. No new replies allowed.