For this project I am suppose to create a data file which includes this info:

Miller Ford Mustang 28000
Miller Ford Escape 23000
Miller Ford Van 32000
Sam_Car Ford Focus 17000
Sam_Car Ford Ranger 18250
Sam_Car Chev Impala 31500
Tina_Sells Chev Camero 33000
Tina_Sells Chev SUV 38000

Then I am suppose to create a program that reads in all the data but uses a control break, one that subtotals each salespersons sales. then it it suppose to display the read data including the subtotal, and earned commission which is 4% of the total sales (subtotal).
This is what I have so far, it read all the data and displays it. I just need help on how to start on the subtotaling for each seller? Can anyone show me an example or lead me in the direction to a solution for my program? Thanks.

///Preprocessive directives
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

//Prototypes
void initialization();
void process ();
void eoj ();
void openIt();
void readIt(); 
void writeIt();
void calculateIt();
void accumulateIt();

//Input Records
ifstream inputFile;
char sSalesPerson[15];
char sMake[10]; 
char sModel [10];
int iSellingPrice;

//Program Variables
int iEarnedCommission;


int main()
{
	cout << "\n\t\tWeekly Car Sales Report\n\n";
	cout << "Salesperson    Make        Model    Selling Price\n";
	cout << "-------------------------------------------------\n";
	initialization();
	
	if (!inputFile.fail())    
	{
		process();
	
	}

	eoj();
	
	return 0;
}

void initialization()
{
	openIt();
	
	return;
}
void process ()
{
	readIt();
	while (!inputFile.eof())
	{
		calculateIt();
		accumulateIt();
		writeIt();
		readIt();
	}





	return;
}
void eoj ()
{
 inputFile.close();
 return;
}
void openIt()
{
	inputFile.open("c:\\auto.dat");
	if (inputFile.fail())
		cout << "AUTO file open failed" << endl;
	return;

}
void readIt()
{
		
		inputFile >> sSalesPerson >> sMake >> sModel >> iSellingPrice;
	

	return;
}
void calculateIt()
{
	
	return;

}
void accumulateIt()
{  
		
	
     return;
}
void writeIt()
{
	cout << left << setw(15) << sSalesPerson << setw(12)<< sMake << setw(12) << sModel <<  setw(12)
		<< iSellingPrice << endl; 
	

	

	return;
}

You should pay attention to how you have divided your problem into functions.

A function like computeCommission(int price) can be useful...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.