This project is based on the banking system, UTT Insurance Limited. Each month the company calculates commission for its employee. UTT Insurance Limited has 5 employees and their names are Denver, Garry, Cindy, Samdaye and Nalinee. Each employee has their respective sales for the month which is recorded in an external file, “sales.txt”. It the total sales is more than one million the commission is 10% of the sales otherwise the commission is 5% of the sales. The external file, “sales.txt” has all the sales for one employee before recording another employee. The end of recording of each teller is noted by ‘E’. For example
Denver 100000 250000 50000 30000 60000 10000 E Garry 100000 40000 50000 120000 300000 50000 80000 120000 E
Write a C++ program that opens the external file, “sales.txt” and reads the data and writes to an external file, “commission.txt” the following information:

Denver Total sales 500000 Commision 25000
Garry Total sales 1210000 Commision 121000

Please read the posting rules; especially pay more attention on Keep It Organized section.

Nice little problem you posted ... there are many ways to code a solution.

Some nice and neat way would be best with clear logic flow.

Probably using a C++ struct ( or class ) would help quite a bit.

Please show us what code you have tried so far.

Then we can see where you are 'stuck' and how to best get you 'un-stuck'.

Also provide a copy of the data file you are using.

If you know about using C++ struct ... here is an hint to a start:

struct Agent
{
    string name;
    vector< int > sales; // dollars in a month //
} ;

And ...
if you know about using stringstream objects ...
hint hint ...
use them here to ease your coding.

This is what I did since my code is not outputting the correct total i dont know how to move foward.The code is supposed to output each person's total sales for the monthe and i also don't know how to do that.

Ok ... It looks like you want to do something like the following ...
(... and it seems also that you do not need to store input lines in an array ... so ... no array needed ...)

open input file as fin
open output file as fout

if fin and fout ok
    While still a next data line in input file 
        read data on line from input file 
        process data in line
        write processed data to output file 

Or more C++ like:

open input file as fin
open output file as fout

if fin and fout ok
     While next data line reads in ok  
        process data in line
        write processed data to output file 

Is this what you wish to do ?

Try to code in the C++ code ... using the ideas above ... and see what you can do and show us what you have ... if you get stuck?

P.S.
Things you will want to get clear in your mind before you start ...
* Does you data file always begin with an int (integer) value, that indicates how many line follow?
* Is there a blank (empty file) line immediately after that int?
* Do all the data records have their own line ... and each line ends with " E" (singlespaceE) character sequence?
* Are all names single names i.e. WITHOUT spaces in the name?
* Is there always 6 numbers after the name and before the " E" on each data file line? (Note that in the example you provided at the top, one record had 6 numbers, the next had 8 numbers.)