I've been working on a piece of code for a while, and it works as it is intended to. Now, though, I'm trying to the code down so that there is one main functions and every "action" is a function that is called. But, I have very little experience with functions. I have been reading up and practicing with them, but am still a little bit lost. What would you recommend doing and how would you go about breaking the code below into functions, so that it still works the same way?

Step 3 - Output:
	* Student information (name, class sections, assignment/date) 
	* Program title/mission statement
	1) Detailed individual employee reports in page format. (Stored in output file #2 and not displayed on monitor):
	Print information until all information is listed, or print "Bad Data...(reason)" after file input data is invalid.
	- Print the employee's information. 
		- Name.
		- Gross Salary.
		- Medical Benefits.
		- Retirement Contribution in percent.
			- Company contribution in dollars.
			- Employee contribution in dollars.
			- Total contributions in dollars.
		- Taxes Owed.
		- Net Salary.
		
	2) Payroll report in tabular form. (Stored in output file #1 and displayed on monitor):
	For each individual employee in the information output table.
		- Print each employee's data on one line until all information (below) is listed: 
			*Note - End output and print "Bad Data...(reason)" if file input data is invalid.
			- Name.
			- Gross Salary.
			- Benefits.
			- Contributions.
			- Taxes.
			- Net Salary.
		
	- Print a complete company pay report:
		- Total Gross Salaries paid.
		- Total Benefits collected.
		- Total Contributions to Retirement Funds.
		- Total Taxes Collected.
		- Total Net Salaries Paid.

************************ End of Algorithm *****************************/	

/************ Code segment *******************************************/
#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
int main()
{
	int skill, benefitType, taxRemainder;
	double hours, contPercent, gross, benefitCost, grossDed, contAmount, taxOwed, netSalary, contTotal, taxID, skillPay;
	double sumGross = 0, sumBenefit = 0, sumContributions = 0, sumTaxes = 0, sumNet = 0;
	string name, benefitName;
	string fileInput1, fileInput2, fileOutput1, fileOutput2;

	ifstream fin, fin1;
	ofstream fout1, fout2; 

	// Program title.		  
	cout << " \t Assignment #5: Company Payroll and Employee Reports." << endl;

	// Program mission statement.
	cout << "This program will prompt user for a data file with a list of a small company's employees, " << endl;
	cout << "and will process the data and generate (1) a payroll report and (2) detailed invidiual employee reports." << endl;

	cout << "--------------------------------------------------------------" << endl << endl;

	cout << "Enter input file name for detailed employee reports in page format: ";	
	getline(cin, fileInput1);
	fin.open(fileInput1.c_str());
	
	if (fin.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		return 0;
	}
	else
	{
		cout << "Enter output file name for detailed employee reports in page format: ";	
		getline(cin, fileOutput1);					
		fout1.open(fileOutput1.c_str()) ;	
		
		fout1 << "Detailed Employee Reports:" << endl;

		fin >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin, name);

		while (!fin.eof())	
		{						
		if (skill == 1)
				skillPay = 15.00;
			else if (skill == 2)
				skillPay = 25.00;
			else if (skill == 3)
				skillPay = 72.00;
			else if (skill == 4)
				skillPay = 125.00;

		if (hours <= 40)
				gross = hours * skillPay;
			else if (hours <= 50)
				gross = (40 * skillPay) + ((hours - 40) * (skillPay * 1.5)); 
			else if (hours <= 60)
				gross = (40 * skillPay) + (10 * (skillPay * 1.5)) + ((hours - 50) * (skillPay * 2));

		if (skill == 1 || benefitType == 0)
			benefitCost = 0;			
		else if (benefitType == 1)	
			benefitCost = 32.50;
		else if (benefitType == 2)	
			benefitCost = 52.50;
		else if (benefitType == 3)	
			benefitCost = 62.50;
			
	contAmount = gross * (contPercent / 100.00);
	contTotal = 2 * contAmount;
	grossDed = gross - contAmount - benefitCost;
	taxRemainder = (grossDed - 5000) / 1000;
			
		if (grossDed <= 2000.00)
				taxOwed = 0;
			else if (grossDed <= 3000.00)
				taxOwed = 0.03 * (grossDed - 2000);
			else if (grossDed <= 4000.00)
				taxOwed = (0.01 * 3000) + (0.05 * (grossDed - 3000));
			else if (grossDed <= 5000.00)
				taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * (grossDed - 4000));
			else if (grossDed > 5000.00)
				taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * 1000) + (taxRemainder / 100.0) * (grossDed - 5000);
				
	netSalary = grossDed - taxOwed;
  
  	if (skill < 1 || skill > 4)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << "Bad data." << endl << "Invalid skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (hours < 0 || hours > 60 )
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Bad data." << endl << "Invalid hours." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << "Bad data." << endl << "Invalid medical benefit code." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (skill != 4 && contPercent != 0)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (contPercent < 0 || contPercent > 5)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}	
	else
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << left << setw(25) << "Retirement Contribution:" << left << contPercent << "%" << endl;
		fout1 << left << setw(25) << "      Company:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Employee:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Total:" << "$" << left << setw(25) << contTotal << endl;
		fout1 << left << setw(25) << "Taxes Owed:" << "$" << left << setw(25) << taxOwed << endl;
		fout1 << left << setw(25) << "Net Salary:" << "$" << left << setw(25) << netSalary << endl << endl;	
	}
	
	fin >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin, name);			
	}   
  fout1.close();
}
	
	cout << endl; 
	
	if (!fin.fail())		
		cout << "Detailed employee reports have been printed in " << fileOutput1 << "." << endl << endl;
	cout << "Enter input file name for company payroll report. (Can be same as first input file.): ";	
	getline(cin, fileInput2);
	fin1.open(fileInput2.c_str());
	
	if (fin1.fail())			
		cout << "Bad input file." << endl << "Program stopped." << endl;
	else
	{
		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);

		cout << "Enter output file name for company payroll report: ";	
		getline(cin, fileOutput2);
		fout2.open(fileOutput2.c_str()) ;
	
	cout << endl;
	cout << "  Overview  " << endl;
	cout << "---------------" << endl;	
	cout << left << setprecision(2) << fixed << showpoint;
	cout << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	cout << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;
	
	fout2 << endl;
	fout2 << "  Overview  " << endl;
	fout2 << "---------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	fout2 << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;

	while (!fin1.eof())	
	{
	cout << left << setw(25) << name;
	fout2 << left << setw(25) << name;
	
	while (!fin1.eof())
	{
	if (skill < 1 || skill > 4)
	{
		cout << "Bad data. \t \t Invalid skill level." << endl;
		fout2 << "Bad data. \t \t Invalid skill level." << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
				break;
	}
	else if (hours < 0 || hours > 60)
	{
		cout << "Bad data. \t \t Invalid hours." << endl;
		fout2 << "Bad data. \t \t Invalid hours." << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
		break;
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		cout << "Bad data. \t \t Invalid benefit code." << endl;
		fout2 << "Bad data. \t \t Invalid benefit code." << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
		break;
	}			
	else if (skill == 1 && benefitType != 0)
	{
		cout << "Bad data. \t \t Invalid benefit type for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid benefit type for skill level." << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
		break;
	}		
	else if (skill != 4 && contPercent != 0)
	{
		cout << "Bad data. \t \t Invalid contribution percent for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid contribution percent for skill level." << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
		break;
	}		
	else if (contPercent < 0 || contPercent > 5)
	{
		cout << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;
		fout2 << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;

		fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
		getline(fin1, name);			
		break;
	}
	else
	{
	if (skill == 1)
			skillPay = 15.00;
		else if (skill == 2)
			skillPay = 25.00;
		else if (skill == 3)
			skillPay = 72.00;
		else if (skill == 4)
			skillPay = 125.00;

	if (hours <= 40)
			gross = hours * skillPay;
		else if (hours <= 50)
			gross = (40 * skillPay) + ((hours - 40) * (skillPay * 1.5)); 
		else if (hours <= 60)
			gross = (40 * skillPay) + (10 * (skillPay * 1.5)) + ((hours - 50) * (skillPay * 2));

	if (skill == 1 || benefitType == 0)
			benefitCost = 0;			
		else if (benefitType == 1)	
			benefitCost = 32.50;
		else if (benefitType == 2)	
			benefitCost = 52.50;
		else if (benefitType == 3)	
			benefitCost = 62.50;
			
	contAmount = gross * (contPercent / 100.00);
	contTotal = 2 * contAmount;
	grossDed = gross - contAmount - benefitCost;
	taxRemainder = (grossDed - 5000) / 1000;
		
	if (grossDed <= 2000.00)
			taxOwed = 0;
		else if (grossDed <= 3000.00)
			taxOwed = 0.03 * (grossDed - 2000);
		else if (grossDed <= 4000.00)
			taxOwed = (0.01 * 3000) + (0.05 * (grossDed - 3000));
		else if (grossDed <= 5000.00)
			taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * (grossDed - 4000));
		else if (grossDed > 5000.00)
			taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * 1000) + (taxRemainder / 100) * (grossDed - 5000);
			
	netSalary = grossDed - taxOwed;

	sumGross += gross;
	sumBenefit += benefitCost;
	sumContributions += contTotal;
	sumTaxes += taxOwed;
	sumNet += netSalary;
  
  	cout << left << setprecision(2) << fixed << showpoint;
	cout << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	cout << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
  	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	fout2 << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
	
	fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin1, name);
	break;
	}
	}	
	}   

	cout << endl << endl;	
	cout << "  Totals  " << endl;
	cout << "-------------" << endl;
	cout << left << setprecision(2) << fixed << showpoint;
	cout << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	cout << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	cout << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	cout << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	cout << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl;

	fout2 << endl << endl;	
	fout2 << "  Totals  " << endl;
	fout2 << "-------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	fout2 << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	fout2 << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	fout2 << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	fout2 << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl << endl;

	fout2.close();
	}
	
	return 0;
}

Thank you so much.

.

i have done a bit work on it. Check it out.
There is a hell lot scope for optimizing your code.
Go thru it and u will know where u can put functions.

Thanks guys. I've been working on it all night. I'm a bit stumped, and was wondering:
1) Am I on the right track, and is it just small details to correct now? Or will I need to overhaul my code (and how?)?
2) My compiler gives me a bunch of syntax errors (especially primary-expression...) that I don't know how to fix. Any help would be great.

Here's the new code, and thanks so much:

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;

// Function Prototypes
void Program_Info (void);        
void Open_File_1(ifstream &fin);
void Output_File_1 (ofstream &fout1);
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
double Skill_Pay (int skill);
double Gross_Pay (double skillPay, double hours);
double Benefit_Cost (int skill, int benefitType);
void Gross_Calculations (double gross, double contPercent, double &contAmount, double &grossDed, int &taxRemainder);
void Taxes_and_Net (double grossDed, int taxRemainder, double &taxOwed, double &netSalary);
void Print_File_1 (ofstream&, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary);

void Open_File_2(ifstream &fin1);
void Output_File_1 (ofstream &fout2);
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
void Print_Head_2 (ofstream &fout2);
void Sum_Calculations (double gross, double benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet);
void Print_Employee_2 (ofstream &fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);
void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet);

int main()
{
	int skill, benefitType, taxRemainder;
	double hours, contPercent, gross, benefitCost, grossDed, contAmount, taxOwed, netSalary, contTotal, taxID, skillPay;
	double sumGross = 0, sumBenefit = 0, sumContributions = 0, sumTaxes = 0, sumNet = 0;
	string name, benefitName;
	string fileInput1, fileInput2, fileOutput1, fileOutput2;

	ifstream fin, fin1;
	ofstream fout1, fout2; 

	Program_Info();
	Open_File_1(fin);
	Output_File_1(fout1);
	
	fout1 << "Detailed Employee Reports:" << endl;

	Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	
	while (!fin.eof())
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, contAmount, grossDed, taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, taxOwed, netSalary);

		Print_File_1 (skill, name, hours, benefitType, gross, contPercent, benefitCost, contAmount, contTotal, taxOwed, netSalary);		

		Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	}   
  
    fout1.close();
}
	
	if (!fin.fail())		
		cout << endl << "Detailed employee reports have been printed in " << fileOutput1 << "." << endl << endl;

	Open_File_2(fin1);
	Output_File_2(fout2);

	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
	Print_Head_2 (ofstream &fout2);

	while (!fin1.eof())	
	{
		cout << left << setw(25) << name;
		fout2 << left << setw(25) << name;
			while (!fin1.eof())
			{
				Print_Employee_2 (skill, hours, benefitType, contPercent, gross, benefitCost, contAmount, taxOwed, netSalary);
				Sum_Calculations (gross, benefitCost, contTotal, taxOwed, netSalary, &sumGross, &sumBenefit, &sumContributions, &sumTaxes, &sumNet)
				Print_Employee_2 (fout2, skill, hours, benefitType, contPercent, gross, benefitCost, contAmount, taxOwed, netSalary);
				break;
			}
	}
	
	Print_Totals_2 (fout2, sumGross, sumBenefit, sumContributions, sumTaxes, sumNet);		

	fout2.close();
	}
	
	return 0;
}


// Function Declarations
 // Individual Reports
void Program_Info (void)
{
	cout << endl;
	cout << "--------------------------------------------------------------" << endl;	
	cout << "Student Name and ID:     xxx" << endl;
	cout << "Course Section:          xxx" << endl;
	cout << "Lab Section:             xxx" << endl;
	cout << "--------------------------------------------------------------" << endl;
  
	// Program title.		  
	cout << " \t Assignment #5: Company Payroll and Employee Reports." << endl;

	// Program mission statement.
	cout << "This program will prompt user for a data file with a list of a small company's employees, " << endl;
	cout << "and will process the data and generate (1) a payroll report and (2) detailed invidiual employee reports." << endl;

	cout << "--------------------------------------------------------------" << endl << endl;
}
     
void Open_File_1(ifstream &fin)
{
	string fileInput1;
	cout << "Enter input file name for detailed employee reports in page format: ";	
	getline(cin, fileInput1);
	fin.open(fileInput1.c_str());
	
	if (fin.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		return 0;
	}
}

void Output_File_1 (fout1)
{
	string fileOutput1;	
	cout << "Enter output file name for detailed employee reports in page format: ";
	getline(cin, fileOutput1);					

	fout1.open(fileOutput1.c_str());
}	
		
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
{
	fin >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin, name);	
}
		
double Skill_Pay (int skill);
{
	if (skill == 1)
			skillPay = 15.00;
		else if (skill == 2)
			skillPay = 25.00;
		else if (skill == 3)
			skillPay = 72.00;
		else if (skill == 4)
			skillPay = 125.00;	
	
	return (skillPay);
}

double Gross_Pay (int skillPay, double hours);
{
	if (hours <= 40)
			gross = hours * skillPay;
		else if (hours <= 50)
			gross = (40 * skillPay) + ((hours - 40) * (skillPay * 1.5)); 
		else if (hours <= 60)
			gross = (40 * skillPay) + (10 * (skillPay * 1.5)) + ((hours - 50) * (skillPay * 2));

	return (gross);
}

double Benefit_Cost (int skill, int benefitType);
{
	if (skill == 1 || benefitType == 0)
		benefitCost = 0;			
	else if (benefitType == 1)	
		benefitCost = 32.50;
	else if (benefitType == 2)	
		benefitCost = 52.50;
	else if (benefitType == 3)	
		benefitCost = 62.50;
		
	return (benefitCost);	
}

void Gross_Calculations (double gross, double contPercent, double &contAmount, double &grossDed, double &taxRemainder);
{
	contAmount = gross * (contPercent / 100.00);
	contTotal = 2 * contAmount;
	grossDed = gross - contAmount - benefitCost;
	taxRemainder = (grossDed - 5000) / 1000;
}

void Taxes_and_Net (double grossDed, double taxRemainder, double &taxOwed, double &netSalary);
{
	if (grossDed <= 2000.00)
		taxOwed = 0;
	else if (grossDed <= 3000.00)
		taxOwed = 0.03 * (grossDed - 2000);
	else if (grossDed <= 4000.00)
		taxOwed = (0.01 * 3000) + (0.05 * (grossDed - 3000));
	else if (grossDed <= 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * (grossDed - 4000));
	else if (grossDed > 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * 1000) + (taxRemainder / 100.0) * (grossDed - 5000);
				
	netSalary = grossDed - taxOwed;
}

void Print_File_1 (ofstream &fout1, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary);	
{
  	if (skill < 1 || skill > 4)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << "Bad data." << endl << "Invalid skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (hours < 0 || hours > 60 )
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Bad data." << endl << "Invalid hours." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << "Bad data." << endl << "Invalid medical benefit code." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (skill != 4 && contPercent != 0)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (contPercent < 0 || contPercent > 5)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}	
	else
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << left << setw(25) << "Retirement Contribution:" << left << contPercent << "%" << endl;
		fout1 << left << setw(25) << "      Company:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Employee:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Total:" << "$" << left << setw(25) << contTotal << endl;
		fout1 << left << setw(25) << "Taxes Owed:" << "$" << left << setw(25) << taxOwed << endl;
		fout1 << left << setw(25) << "Net Salary:" << "$" << left << setw(25) << netSalary << endl << endl;	
	}
}
			
 // Payroll Report
void Open_File_2(ifstream &fin1)
{
	string fileInput2;
	
	cout << "Enter input file name for company payroll report. (Can be same as first input file.): ";
	getline(cin, fileInput2);
	fin1.open(fileInput2.c_str());
	
	if (fin1.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		return 0;
	}	
}

void Output_File_2 (fout2)
{
	string fileOutput1;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}	
				
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
{
	fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin1, name);	
}
 
void Print_Head_2 (ofstream &fout2);
{
	cout << endl;
	cout << "  Overview  " << endl;
	cout << "---------------" << endl;	
	cout << left << setprecision(2) << fixed << showpoint;
	cout << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	cout << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;
	
	fout2 << endl;
	fout2 << "  Overview  " << endl;
	fout2 << "---------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	fout2 << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;	
}	

void Print_Employee_2 (int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);
{
	if (skill < 1 || skill > 4)
	{
		cout << "Bad data. \t \t Invalid skill level." << endl;
		fout2 << "Bad data. \t \t Invalid skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}
	else if (hours < 0 || hours > 60)
	{
		cout << "Bad data. \t \t Invalid hours." << endl;
		fout2 << "Bad data. \t \t Invalid hours." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		cout << "Bad data. \t \t Invalid benefit code." << endl;
		fout2 << "Bad data. \t \t Invalid benefit code." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}			
	else if (skill == 1 && benefitType != 0)
	{
		cout << "Bad data. \t \t Invalid benefit type for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid benefit type for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (skill != 4 && contPercent != 0)
	{
		cout << "Bad data. \t \t Invalid contribution percent for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid contribution percent for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (contPercent < 0 || contPercent > 5)
	{
		cout << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;
		fout2 << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}
	else
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, &contAmount, &grossDed, &taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, &taxOwed, &netSalary);
	}
}
	
void Sum_Calculations (int gross, int benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet)
{
	sumGross += gross;
	sumBenefit += benefitCost;
	sumContributions += contTotal;
	sumTaxes += taxOwed;
	sumNet += netSalary;	
}

void Print_Employee_2 (ofstream &fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);
{
	cout << left << setprecision(2) << fixed << showpoint;
	cout << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	cout << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
  	
  	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	fout2 << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
	
	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
}

void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet)
{
	cout << endl << endl;	
	cout << "  Totals  " << endl;
	cout << "-------------" << endl;
	cout << left << setprecision(2) << fixed << showpoint;
	cout << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	cout << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	cout << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	cout << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	cout << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl;

	fout2 << endl << endl;	
	fout2 << "  Totals  " << endl;
	fout2 << "-------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	fout2 << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	fout2 << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	fout2 << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	fout2 << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl << endl;	
}

First step in debugging. Make, make your main look like this:

int main ()
{
   return 0;
}

If that gets rid of the errors, then at least your functions compile, which of course doesn't mean they are correct. If it doesn't compile, start looking at the errors. Look for any "can't find identifier" errors or "unmatched bracket" errors, "redeclaration" errors, "expected semicolon" errors, stuff like that. A single bracket or semicolon missing can cause the errors to avalanche. You should be fixing errors, then recompiling. For the most part, go from top to bottom.

You've violated the main rule of programming/debugging, which is "Don't do too much at once." You should start with working code, than change once thing at a time, compiling and fixing errors as you go. Right now you have too many, especially if this is all new to you. I'd go back to your working code without functions and sort of start over. First step: keep everything the same, but change the output code to be in functions. When that works, change the calculation code to be in functions. When that works, change the file input code to be in functions. That's three separate very broad categories, each of which are quite enough on their own to focus on. Tackling all at once is asking for trouble.

First step in debugging. Make, make your main look like this:

int main ()
{
   return 0;
}

If that gets rid of the errors, then at least your functions compile, which of course doesn't mean they are correct. If it doesn't compile, start looking at the errors. Look for any "can't find identifier" errors or "unmatched bracket" errors, "redeclaration" errors, "expected semicolon" errors, stuff like that. A single bracket or semicolon missing can cause the errors to avalanche. You should be fixing errors, then recompiling. For the most part, go from top to bottom.

You've violated the main rule of programming/debugging, which is "Don't do too much at once." You should start with working code, than change once thing at a time, compiling and fixing errors as you go. Right now you have too many, especially if this is all new to you. I'd go back to your working code without functions and sort of start over. First step: keep everything the same, but change the output code to be in functions. When that works, change the calculation code to be in functions. When that works, change the file input code to be in functions. That's three separate very broad categories, each of which are quite enough on their own to focus on. Tackling all at once is asking for trouble.

That makes sense. What do you recommend for compiling/debugging? I've been using notepad++ to edit the code and then upload to unix each time I want to check errors.

Is there an easier way? Perhaps one using notepad++ or sublime or another program?

You can definitely skip the "upload to Linux" step. Not sure if you're a student and have a home computer and are uploading and compiling to a Linux server at school or something. You're only using the standard headers, so everything is 100% portable and thus should compile and run exactly the same in Windows and Linux, so you can just do everything on Windows. Notepad++ (which I've never used) appears not to have its own compiler, so you'd have to download and install one like mingw. http://www.mingw.org/

Or install Dev C++ or Code Blocks, both of which use mingw. Or Visual C++ from Microsoft or NetBeans. All of these have IDEs with editors, debuggers, compilers, etc. or you can continue with Notepad++ as the editor and compile from the command line. Editing and compiling are separate processes. There is also cygwin, which is sort of "Linux for Windows". Lots of options, but as I mentioned, all of your code is completely the same for both Windows and Linux.

Best advice would be to install Visual C++ or Code Blocks and use them instead of Notepad C++. You'll eventually need to use a debugger and these provide them. If you use Visual C++, always pick a "console" project, make it an empty project, and don't use the precompiled headers. It'll make the upload to Linux much less frustrating.

You can definitely skip the "upload to Linux" step. Not sure if you're a student and have a home computer and are uploading and compiling to a Linux server at school or something. You're only using the standard headers, so everything is 100% portable and thus should compile and run exactly the same in Windows and Linux, so you can just do everything on Windows. Notepad++ (which I've never used) appears not to have its own compiler, so you'd have to download and install one like mingw. http://www.mingw.org/

Or install Dev C++ or Code Blocks, both of which use mingw. Or Visual C++ from Microsoft or NetBeans. All of these have IDEs with editors, debuggers, compilers, etc. or you can continue with Notepad++ as the editor and compile from the command line. Editing and compiling are separate processes. There is also cygwin, which is sort of "Linux for Windows". Lots of options, but as I mentioned, all of your code is completely the same for both Windows and Linux.

Best advice would be to install Visual C++ or Code Blocks and use them instead of Notepad C++. You'll eventually need to use a debugger and these provide them. If you use Visual C++, always pick a "console" project, make it an empty project, and don't use the precompiled headers. It'll make the upload to Linux much less frustrating.

Okay, I have codeblocks, but have no experience with it. To debug/check my code, do I just copy and paste the code over from notepad++ and click debug? The reason I stopped using it was because the debug feature wouldn't work when I tried to use it.

You can only debug a PROJECT in Code Blocks. You cannot debug a FILE. Projects are easy to make in Code Blocks and can consist of a file. You can always edit the file in Notepad++ and compile and/or debug using Code Blocks.

  1. Create a file and save it in Notepad++
  2. Create a new console project in Code Blocks
  3. When you do that, a file called main.cpp is created for you. Remove it from the project.
  4. Add your newly created file from Notepad++ to your Code Blocks project.
  5. Compile, run, debug the project in Code Blocks.
  6. You can now edit the file in either Code Blocks or Notepad++. If you edit it in Notepad++, Code Blocks may tell you it's been modified in another program and ask if you want to reload, rebuild it. Click yes.
  7. Add whatever breakpoints you want in Code Blocks and try running in debug mode. Start with a few "Hello World" and "Count to 10" type programs till you get the hang of it.

You can also ditch Notepad++ altogether and use the Code Blocks editor. My guess is you tried to debug a file that wasn't a project. Can't be done. it needs to be a project to use the debuger. You can use the plain old Code Blocks compiler on a regular file, but not the debugger. Google some Code Blocks tutorials, set aside about fifteen minutes on how to use it and its debugger, and practice on a few "Hello World" type programs and you'll be off and running! Once you start using an IDE, you'll never want to program without one.

may i get any help here?huhu...i'm really didn'r know how to write these program..since i'm just learn this c++ subject..any one can help me?
" The number of bacteria, BigFoot, in certain culture that is subject to refrigeration and be approximated by the equation BigFoot = 30350e-0.0234t, where e is the irritional number 3.7, t ia the time, in hour, that hte culture has been refregerated. using this equation, write a function named bigfoot () that prompts the user for a value of time, calculates the number od bacteria in the culture and displays the result."

Thanks, dudes. I'm going to work at it for an hour or two, and post back with any questions.

A few things to start, though:
1) I'm a bit confused as to when to use/declare global variables and when to use/declare local variables. I understand their scopes, but do you usually use one for passing by value and the other for passing by reference?

2) To be clear, is it:
Function Prototype: datatype functionname (parameter list with types and identifiers of what is to be passed; include any & for references);

Function Call: functionname (parameter list with only names of identifiers; no &'s or datatype);

Function Definition: datatype functionname (paramter list with data type and name received from main; include &'s for references)

3) Can you tell if my file streams (input and output) and reading them are okay?

This is tedious. And I'm a bit desperate. I still can't fix a numbers of errors, despite working at this since early this morning. And ideas?

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;

// Function Prototypes
void Program_Info (void);        
void Open_File_1(ifstream &fin);
void Output_File_1 (ofstream &fout1);
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
double Skill_Pay (int skill);
double Gross_Pay (double skillPay, double hours);
double Benefit_Cost (int skill, int benefitType);
void Gross_Calculations (double gross, double contPercent, double &contAmount, double &contTotal, double &benefitCost, double &grossDed, int &taxRemainder);
void Taxes_and_Net (double grossDed, int taxRemainder, double &taxOwed, double &netSalary);

void Print_File_1 (ofstream &fout1, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary);
void Open_File_2(ifstream &fin1);
void Output_File_2 (ofstream &fout2);
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
void Print_Head_2 (ofstream &fout2);
void Sum_Calculations (double gross, double benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet);
void Print_Employee_2 (ofstream &fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);
void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet);

int main()
{
	int skill, benefitType, taxRemainder;
	double hours, contPercent, gross, benefitCost, grossDed, contAmount, taxOwed, netSalary, contTotal, taxID, skillPay;
	double sumGross = 0, sumBenefit = 0, sumContributions = 0, sumTaxes = 0, sumNet = 0;
	string name, benefitName;
	string fileInput1, fileInput2, fileOutput1, fileOutput2;

	ifstream fin, fin1;
	ofstream fout1, fout2; 

	Program_Info();
		Open_File_1(fin);
		Output_File_1(fout1);
	   
	fout1 << "Detailed Employee Reports:" << endl;

	Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	
	while (!fin.eof())
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, contAmount, contTotal, benefitCost, grossDed, taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, taxOwed, netSalary);

		Print_File_1(fout1, skill, name, hours, benefitType, gross, contPercent, benefitCost, contAmount, contTotal, taxOwed, netSalary);		

		Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	}   
           fout1.close();
	   
	if (!fin.fail())		
		cout << "Detailed employee reports have been printed." << endl << endl;

	Open_File_2(fin1);
	Output_File_2(fout2);

	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
	Print_Head_2 (fout2);

	while (!fin1.eof())	
	{
		cout << left << setw(25) << name;
		fout2 << left << setw(25) << name;
			while (!fin1.eof())
			{
				Print_Employee_2 (fout2, skill, hours, benefitType, contPercent, gross, benefitCost, contAmount, taxOwed, netSalary);
				Sum_Calculations (gross, benefitCost, contTotal, taxOwed, netSalary, sumGross, sumBenefit, sumContributions, sumTaxes, sumNet);
				Print_Employee_2 (fout2, skill, hours, benefitType, contPercent, gross, benefitCost, contAmount, taxOwed, netSalary);
				break;
			}
	}
	
	Print_Totals_2 (fout2, sumGross, sumBenefit, sumContributions, sumTaxes, sumNet);		

	fout2.close();
	
	return 0;
}

// Function Declarations
 // Individual Reports
void Program_Info (void)
{
	cout << endl;
	cout << "--------------------------------------------------------------" << endl;	
	cout << "Student Name and ID:     ss7" << endl;
	cout << "Course Section:          ss01" << endl;
	cout << "Lab Section:            ss05" << endl;
	cout << "--------------------------------------------------------------" << endl;
  
	// Program title.		  
	cout << " \t Assignment #5: Company Payroll and Employee Reports." << endl;

	// Program mission statement.
	cout << "This program will prompt user for a data file with a list of a small company's employees, " << endl;
	cout << "and will process the data and generate (1) a payroll report and (2) detailed invidiual employee reports." << endl;

	cout << "--------------------------------------------------------------" << endl << endl;
}
  
void Open_File_1(ifstream &fin)
{
	string fileInput1;
	cout << "Enter input file name for detailed employee reports in page format: ";	
	getline(cin, fileInput1);
	fin.open(fileInput1.c_str());
	
	if (fin.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		exit(1);
	}
}

void Output_File_1 (ofstream &fout1)
{
	string fileOutput1;	
	cout << "Enter output file name for detailed employee reports in page format: ";
	getline(cin, fileOutput1);					

	fout1.open(fileOutput1.c_str());
}	
		
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name)
{
	fin >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin, name);	
}
		
double Skill_Pay (int skill)
{
  double skillPay;
	if (skill == 1)
			skillPay = 15.00;
		else if (skill == 2)
			skillPay = 25.00;
		else if (skill == 3)
			skillPay = 72.00;
		else if (skill == 4)
			skillPay = 125.00;	
	
	return (skillPay);
}

double Gross_Pay (int skillPay, double hours)
{
  double gross;
	if (hours <= 40)
			gross = hours * skillPay;
		else if (hours <= 50)
			gross = (40 * skillPay) + ((hours - 40) * (skillPay * 1.5)); 
		else if (hours <= 60)
			gross = (40 * skillPay) + (10 * (skillPay * 1.5)) + ((hours - 50) * (skillPay * 2));

	return (gross);
}

double Benefit_Cost (int skill, int benefitType)
{
  double benefitCost;
	if (skill == 1 || benefitType == 0)
		benefitCost = 0;			
	else if (benefitType == 1)	
		benefitCost = 32.50;
	else if (benefitType == 2)	
		benefitCost = 52.50;
	else if (benefitType == 3)	
		benefitCost = 62.50;
		
	return (benefitCost);	
}

void Gross_Calculations (double gross, double contPercent, double &contAmount, double &contTotal, double benefitCost, double &grossDed, int &taxRemainder)
{
	
	contAmount = gross * (contPercent / 100.00);
	contTotal = 2 * contAmount;
	grossDed = gross - contAmount - benefitCost;
	taxRemainder = (grossDed - 5000) / 1000;
}

void Taxes_and_Net (double grossDed, int taxRemainder, double &taxOwed, double &netSalary)
{
	if (grossDed <= 2000.00)
		taxOwed = 0;
	else if (grossDed <= 3000.00)
		taxOwed = 0.03 * (grossDed - 2000);
	else if (grossDed <= 4000.00)
		taxOwed = (0.01 * 3000) + (0.05 * (grossDed - 3000));
	else if (grossDed <= 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * (grossDed - 4000));
	else if (grossDed > 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * 1000) + (taxRemainder / 100.0) * (grossDed - 5000);
				
	netSalary = grossDed - taxOwed;
}

void Print_File_1 (ofstream &fout1, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary)	
{
  	if (skill < 1 || skill > 4)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << "Bad data." << endl << "Invalid skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (hours < 0 || hours > 60 )
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Bad data." << endl << "Invalid hours." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << "Bad data." << endl << "Invalid medical benefit code." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (skill != 4 && contPercent != 0)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (contPercent < 0 || contPercent > 5)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}	
	else
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << left << setw(25) << "Retirement Contribution:" << left << contPercent << "%" << endl;
		fout1 << left << setw(25) << "      Company:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Employee:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Total:" << "$" << left << setw(25) << contTotal << endl;
		fout1 << left << setw(25) << "Taxes Owed:" << "$" << left << setw(25) << taxOwed << endl;
		fout1 << left << setw(25) << "Net Salary:" << "$" << left << setw(25) << netSalary << endl << endl;	
	}
}
			
 // Payroll Report
void Open_File_2(ifstream &fin1)
{
	string fileInput2;
	
	cout << "Enter input file name for company payroll report. (Can be same as first input file.): ";
	getline(cin, fileInput2);
	fin1.open(fileInput2.c_str());
	
	if (fin1.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		exit(1);
	}	
}

void Output_File_2 (fout2)
{
	string fileOutput1;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}	
				
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name)
{
	fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin1, name);	
}
 
void Print_Head_2 (ofstream &fout2)
{
	cout << endl;
	cout << "  Overview  " << endl;
	cout << "---------------" << endl;	
	cout << left << setprecision(2) << fixed << showpoint;
	cout << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	cout << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;
	
	fout2 << endl;
	fout2 << "  Overview  " << endl;
	fout2 << "---------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	fout2 << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;	
}	

void Print_Employee_2 (int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary)
{
	if (skill < 1 || skill > 4)
	{
		cout << "Bad data. \t \t Invalid skill level." << endl;
		fout2 << "Bad data. \t \t Invalid skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}
	else if (hours < 0 || hours > 60)
	{
		cout << "Bad data. \t \t Invalid hours." << endl;
		fout2 << "Bad data. \t \t Invalid hours." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		cout << "Bad data. \t \t Invalid benefit code." << endl;
		fout2 << "Bad data. \t \t Invalid benefit code." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}			
	else if (skill == 1 && benefitType != 0)
	{
		cout << "Bad data. \t \t Invalid benefit type for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid benefit type for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (skill != 4 && contPercent != 0)
	{
		cout << "Bad data. \t \t Invalid contribution percent for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid contribution percent for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}		
	else if (contPercent < 0 || contPercent > 5)
	{
		cout << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;
		fout2 << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		break;
	}
	else
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, &contAmount, &grossDed, &taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, &taxOwed, &netSalary);
	}
}
	
void Sum_Calculations (int gross, int benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet)
{
	sumGross += gross;
	sumBenefit += benefitCost;
	sumContributions += contTotal;
	sumTaxes += taxOwed;
	sumNet += netSalary;	
}

void Print_Employee_2 (ofstream &fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary)
{
	cout << left << setprecision(2) << fixed << showpoint;
	cout << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	cout << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
  	
  	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	fout2 << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
	
	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
}

void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet)
{
	cout << endl << endl;	
	cout << "  Totals  " << endl;
	cout << "-------------" << endl;
	cout << left << setprecision(2) << fixed << showpoint;
	cout << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	cout << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	cout << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	cout << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	cout << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl;

	fout2 << endl << endl;	
	fout2 << "  Totals  " << endl;
	fout2 << "-------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	fout2 << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	fout2 << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	fout2 << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	fout2 << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl << endl;	
}

If you are brand new to functions, this is way too big of a program in my opinion. I would set it aside for now and work with something much smaller so that errors like this jump out at you. After a while, the problem will be obvious because you'll have seen them a lot.

void Output_File_2 (fout2)
{
	string fileOutput1;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}

Right off the bat, there's an error in on line 1. Functions must specify the type as well as the variable name. What is fout2's type? Well, from your previous declaration up top on line 21, it's this:

void Output_File_2 (ofstream &fout2);

What happened to the ofstream& part? It needs to be there. Just copy and paste it directly from line 21 and remove the semicolon:

void Output_File_2 (ofstream& fout2)
{
	string fileOutput1;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}

Now, what's fileOutput2? I see a fileOutput1 that's declared, but not used and a fileOutput2 that's used but not declared. Since the function is called Output_File2, I assume it's supposed to be this:

void Output_File_2 (ofstream& fout2)
{
	string fileOutput2;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}

Fix, recompile. Go to the next error. Look at this function on line 314:

void Print_Employee_2 (int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary)

Look at line 319 inside of the function:

fout2 << "Bad data. \t \t Invalid skill level." << endl;

Is fout2 in the parameter list? No? Then you have to either declare it as a local variable inside the function or you need to pass it to the function. You probably want to pass it to the function like you did in the last function, so add it:

void Print_Employee_2 (ofstream& fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary)

And look, it now matches your declaration on line 25:

void Print_Employee_2 (ofstream &fout2, int skill, double hours, int benefitType, double contPercent, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);

All of your function declarations need to match the actual functions themselves. If you see an error with the word "redeclaration" in it, that's a great tipoff that they don't match. Make them match again. Recompile. Go to the next error.

Okay, I've tried everything that was mentioned, and I can run the program. But, it doesn't work as it should. The program is due by 12:00am and I really need help.

If you have the time, please take a look and advise.

#include <iostream>
#include <string>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;

// Function Prototypes
void Program_Info (void);        
void Open_File_1(ifstream &fin);
void Output_File_1 (ofstream &fout1);
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
double Skill_Pay (int skill);
double Gross_Pay (double skillPay, double hours);
double Benefit_Cost (int skill, int benefitType);
void Gross_Calculations (double gross, double contPercent, double &contAmount, double &contTotal, double &benefitCost, double &grossDed, int &taxRemainder);
void Taxes_and_Net (double grossDed, int taxRemainder, double &taxOwed, double &netSalary);

void Print_File_1 (ofstream &fout1, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary);
void Open_File_2(ifstream &fin1);
void Output_File_2 (ofstream &fout2);
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);
void Print_Head_2 (ofstream &fout2);
void Print_Employee_2 (ofstream &fout2, ifstream &fin1, int skill, double hours, int benefitType, double contPercent, double taxID, string name, double skillPay, double &gross, double &benefitCost, double &contAmount, double &contTotal, double &grossDed, int &taxRemainder, double &taxOwed, double &netSalary);
void Sum_Calculations (double gross, double benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet);
void Print_Employee_Data_2 (ofstream &fout2, ifstream &fin1, int skill, double hours, int benefitType, double contPercent, double taxID, string name, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary);
void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet);

int main()
{
	int skill, benefitType, taxRemainder;
	double hours, contPercent, gross, benefitCost, grossDed, contAmount, taxOwed, netSalary, contTotal, taxID, skillPay;
	double sumGross = 0, sumBenefit = 0, sumContributions = 0, sumTaxes = 0, sumNet = 0;
	string name, benefitName;
	string fileInput1, fileInput2, fileOutput1, fileOutput2;

	ifstream fin, fin1;
	ofstream fout1, fout2; 

	Program_Info();
		Open_File_1(fin);
		Output_File_1(fout1);
	   
	fout1 << "Detailed Employee Reports:" << endl;

	Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	
	while (!fin.eof())
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, contAmount, contTotal, benefitCost, grossDed, taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, taxOwed, netSalary);

		Print_File_1(fout1, skill, name, hours, benefitType, gross, contPercent, benefitCost, contAmount, contTotal, taxOwed, netSalary);		

		Read_Data_1(fin, skill, benefitType, contPercent, hours, taxID, name);
	}   
           fout1.close();
	   
	if (!fin.fail())		
		cout << "Detailed employee reports have been printed." << endl << endl;

	Open_File_2(fin1);
	Output_File_2(fout2);

	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
	Print_Head_2 (fout2);

	while (!fin1.eof())	
	{
		cout << left << setw(25) << name;
		fout2 << left << setw(25) << name;
			while (!fin1.eof())
			{
				Print_Employee_2 (fout2, fin1, skill, hours, benefitType, contPercent, taxID, name, skillPay, gross, benefitCost, contAmount, contTotal, grossDed, taxRemainder, taxOwed, netSalary);
				Sum_Calculations (gross, benefitCost, contTotal, taxOwed, netSalary, sumGross, sumBenefit, sumContributions, sumTaxes, sumNet);
				Print_Employee_Data_2 (fout2, fin1, skill, hours, benefitType, contPercent, taxID, name, gross, benefitCost, contAmount, taxOwed, netSalary);
				break;
			}
	}

	Print_Totals_2 (fout2, sumGross, sumBenefit, sumContributions, sumTaxes, sumNet);		

	fout2.close();
	
	return 0;
}

// Function Declarations
 // Individual Reports
void Program_Info (void)
{
	cout << endl;
	cout << "--------------------------------------------------------------" << endl;	
	cout << "Student Name and ID:     539807" << endl;
	cout << "Course Section:          CSC9901" << endl;
	cout << "Lab Section:             #05" << endl;
	cout << "--------------------------------------------------------------" << endl;
  
	// Program title.		  
	cout << " \t Assignment #6: Company Payroll and Employee Reports (Using Functions)." << endl;

	// Program mission statement.
	cout << "This program will prompt user for a data file with a list of a small company's employees, " << endl;
	cout << "and will process the data and generate (1) a payroll report and (2) detailed invidiual employee reports." << endl;

	cout << "--------------------------------------------------------------" << endl << endl;
}
  
void Open_File_1(ifstream &fin)
{
	string fileInput1;
	cout << "Enter input file name for detailed employee reports in page format: ";	
	getline(cin, fileInput1);
	fin.open(fileInput1.c_str());
	
	if (fin.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		exit(1);
	}
}

void Output_File_1 (ofstream &fout1)
{
	string fileOutput1;	
	cout << "Enter output file name for detailed employee reports in page format: ";
	getline(cin, fileOutput1);					

	fout1.open(fileOutput1.c_str());
}	
		
void Read_Data_1 (ifstream &fin, int skill, int benefitType, double contPercent, double hours, double taxID, string name)
{
	fin >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin, name);	
}
		
double Skill_Pay (int skill)
{
  double skillPay;
	if (skill == 1)
			skillPay = 15.00;
		else if (skill == 2)
			skillPay = 25.00;
		else if (skill == 3)
			skillPay = 72.00;
		else if (skill == 4)
			skillPay = 125.00;	
	
	return (skillPay);
}

double Gross_Pay (double skillPay, double hours)
{
  double gross;
	if (hours <= 40)
			gross = hours * skillPay;
		else if (hours <= 50)
			gross = (40 * skillPay) + ((hours - 40) * (skillPay * 1.5)); 
		else if (hours <= 60)
			gross = (40 * skillPay) + (10 * (skillPay * 1.5)) + ((hours - 50) * (skillPay * 2));

	return (gross);
}

double Benefit_Cost (int skill, int benefitType)
{
  double benefitCost;
	if (skill == 1 || benefitType == 0)
		benefitCost = 0;			
	else if (benefitType == 1)	
		benefitCost = 32.50;
	else if (benefitType == 2)	
		benefitCost = 52.50;
	else if (benefitType == 3)	
		benefitCost = 62.50;
		
	return (benefitCost);	
}

void Gross_Calculations (double gross, double contPercent, double &contAmount, double &contTotal, double &benefitCost, double &grossDed, int &taxRemainder)
{
	
	contAmount = gross * (contPercent / 100.00);
	contTotal = 2 * contAmount;
	grossDed = gross - contAmount - benefitCost;
	taxRemainder = (grossDed - 5000) / 1000;
}

void Taxes_and_Net (double grossDed, int taxRemainder, double &taxOwed, double &netSalary)
{
	if (grossDed <= 2000.00)
		taxOwed = 0;
	else if (grossDed <= 3000.00)
		taxOwed = 0.03 * (grossDed - 2000);
	else if (grossDed <= 4000.00)
		taxOwed = (0.01 * 3000) + (0.05 * (grossDed - 3000));
	else if (grossDed <= 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * (grossDed - 4000));
	else if (grossDed > 5000.00)
		taxOwed = (0.01 * 3000) + (0.05 * 1000) + (0.07 * 1000) + (taxRemainder / 100.0) * (grossDed - 5000);
				
	netSalary = grossDed - taxOwed;
}

void Print_File_1 (ofstream &fout1, int skill, string name, double hours, int benefitType, double gross, double contPercent, double benefitCost, double contAmount, double contTotal, double taxOwed, double netSalary)	
{
  	if (skill < 1 || skill > 4)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << "Bad data." << endl << "Invalid skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (hours < 0 || hours > 60 )
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Bad data." << endl << "Invalid hours." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << "Bad data." << endl << "Invalid medical benefit code." << endl << "Employee data output terminated." << endl << endl;   
	}		
	else if (skill != 4 && contPercent != 0)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}
	else if (contPercent < 0 || contPercent > 5)
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << "Bad data." << endl <<"Invalid retirement contributions for skill level." << endl << "Employee data output terminated." << endl << endl;   
	}	
	else
	{
		fout1 << left << setprecision(2) << fixed << showpoint << setw(25);
		fout1 << "------------------------------------------------" << endl;
		fout1 << left << setw(25) << "Name:" << left << setw(25) << name << endl;
		fout1 << left << setw(25) << "Gross Salary:" << "$" << left << setw(25) << gross << endl;   
		fout1 << left << setw(25) << "Medical Benefits:" << "$" << left << setw(25) << benefitCost << endl;
		fout1 << left << setw(25) << "Retirement Contribution:" << left << contPercent << "%" << endl;
		fout1 << left << setw(25) << "      Company:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Employee:" << "$" << left << setw(25) << contAmount << endl;
		fout1 << left << setw(25) << "      Total:" << "$" << left << setw(25) << contTotal << endl;
		fout1 << left << setw(25) << "Taxes Owed:" << "$" << left << setw(25) << taxOwed << endl;
		fout1 << left << setw(25) << "Net Salary:" << "$" << left << setw(25) << netSalary << endl << endl;	
	}
}
			
 // Payroll Report
void Open_File_2(ifstream &fin1)
{
	string fileInput2;
	
	cout << "Enter input file name for company payroll report. (Can be same as first input file.): ";
	getline(cin, fileInput2);
	fin1.open(fileInput2.c_str());
	
	if (fin1.fail())			
	{
		cout << "Bad input file." << endl << "Program stopped." << endl;
		exit(1);
	}	
}

void Output_File_2 (ofstream &fout2)
{
	string fileOutput2;	
	cout << "Enter output file name for company payroll report: ";	
	getline(cin, fileOutput2);
	
	fout2.open(fileOutput2.c_str());
}	
				
void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name)
{
	fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
	getline(fin1, name);	
}
 
void Print_Head_2 (ofstream &fout2)
{
	cout << endl;
	cout << "  Overview  " << endl;
	cout << "---------------" << endl;	
	cout << left << setprecision(2) << fixed << showpoint;
	cout << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	cout << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;
	
	fout2 << endl;
	fout2 << "  Overview  " << endl;
	fout2 << "---------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << left << setw(25) << " Name" << setw(26) << "Gross Salary" << setw(26) << "Benefits";
	fout2 << left << setw(26) << "Contributions" << setw(26) << "Taxes" << setw(26) << "Net Salary" << endl;	
}	

void Print_Employee_2 (ofstream &fout2, ifstream &fin1, int skill, double hours, int benefitType, double contPercent, double taxID, string name, double skillPay, double &gross, double &benefitCost, double &contAmount, double &contTotal, double &grossDed, int &taxRemainder, double &taxOwed, double &netSalary)
{
	if (skill < 1 || skill > 4)
	{
		cout << "Bad data. \t \t Invalid skill level." << endl;
		fout2 << "Bad data. \t \t Invalid skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}
	else if (hours < 0 || hours > 60)
	{
		cout << "Bad data. \t \t Invalid hours." << endl;
		fout2 << "Bad data. \t \t Invalid hours." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}		
	else if (benefitType < 0 || benefitType > 3)
	{
		cout << "Bad data. \t \t Invalid benefit code." << endl;
		fout2 << "Bad data. \t \t Invalid benefit code." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}			
	else if (skill == 1 && benefitType != 0)
	{
		cout << "Bad data. \t \t Invalid benefit type for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid benefit type for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}		
	else if (skill != 4 && contPercent != 0)
	{
		cout << "Bad data. \t \t Invalid contribution percent for skill level." << endl;
		fout2 << "Bad data. \t \t Invalid contribution percent for skill level." << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}		
	else if (contPercent < 0 || contPercent > 5)
	{
		cout << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;
		fout2 << "Bad data. \t \t Invalid contribution: " << contPercent << "%" << endl;

		Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
		exit(1);
	}
	else
	{
		Skill_Pay (skill);
		Gross_Pay (skillPay, hours);
		Benefit_Cost (skill, benefitType);
		Gross_Calculations (gross, contPercent, contAmount, contTotal, benefitCost, grossDed, taxRemainder);
		Taxes_and_Net (grossDed, taxRemainder, taxOwed, netSalary);
	}
}
	
void Sum_Calculations (double gross, double benefitCost, double contTotal, double taxOwed, double netSalary, double &sumGross, double &sumBenefit, double &sumContributions, double &sumTaxes, double &sumNet)
{
	sumGross += gross;
	sumBenefit += benefitCost;
	sumContributions += contTotal;
	sumTaxes += taxOwed;
	sumNet += netSalary;	
}

void Print_Employee_Data_2 (ofstream &fout2, ifstream &fin1, int skill, double hours, int benefitType, double contPercent, double taxID, string name, double gross, double benefitCost, double contAmount, double taxOwed, double netSalary)
{
	cout << left << setprecision(2) << fixed << showpoint;
	cout << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	cout << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
  	
  	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << "$" << left << setw(25) << gross << "$" << left << setw(25) << benefitCost << "$" << left << setw(25) << contAmount;
	fout2 << "$" << left << setw(25) << taxOwed << "$" << left << setw(25) << netSalary << endl; 
	
	Read_Data_2(fin1, skill, benefitType, contPercent, hours, taxID, name);
}

void Print_Totals_2 (ofstream &fout2, double sumGross, double sumBenefit, double sumContributions, double sumTaxes, double sumNet)
{
	cout << endl << endl;	
	cout << "  Totals  " << endl;
	cout << "-------------" << endl;
	cout << left << setprecision(2) << fixed << showpoint;
	cout << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	cout << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	cout << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	cout << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	cout << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl;

	fout2 << endl << endl;	
	fout2 << "  Totals  " << endl;
	fout2 << "-------------" << endl;
	fout2 << left << setprecision(2) << fixed << showpoint;
	fout2 << setw(44) << "Total Gross Salaries paid:" << "$" << left << setw(25) << sumGross << endl;
	fout2 << setw(44) << "Total Benefits collected:" << "$" << left << setw(25) << sumBenefit << endl;
	fout2 << setw(44) << "Total Contributions to Retirement Funds:" << "$" << left << setw(25) << sumContributions << endl;
	fout2 << setw(44) << "Total Taxes collected:" << "$" << left << setw(25) << sumTaxes << endl;
	fout2 << setw(44) << "Total Net Salaries paid:" << "$" << left << setw(25) << sumNet << endl << endl;	
}

As it turns out, my teacher gave an extension til tomorrow for a 10% point deduction.

I know the code is close to working, and it runs with syntax error, but it only outputs "bad data." I think there's a problem with the function calling/passing, but can't find/fix them for the life of me.

Any help would be tremendously appreciated.

As it turns out, my teacher gave an extension til tomorrow for a 10% point deduction.

I know the code is close to working, and it runs with syntax error, but it only outputs "bad data." I think there's a problem with the function calling/passing, but can't find/fix them for the life of me.

Any help would be tremendously appreciated.

It gives you "Bad data" where (what line number?) and with what input (we don't have an input file)?

There are a few major categories this could be because of:

  1. Wrong filename or file doesn't exist. Check to make sure it does.
  2. File is there but is not opened. Check to make sure you're actually reading something in. Some simple cout statements will do the trick here (rememebr to delete the cout statements when you're done).
  3. File is not in the format that the program expects it to be. Look at the file visually and check. If it looks OK, read in the input and immediately display it and make sure the variables contain the file contents.
  4. Parameter passing problems. Display the contents of the parameters at the top of each function to make sure they are passed correctly. Also make display them BEFORE you pas them, make sure they match what's received in the functions.
  5. Etc. etc. etc. There are a whole bunch of categories. Your description of the problem is too vague though, so I'll stop here. Get some nice, very simple, short input files with values that you can calculate on paper and check immediately. Thus you don't read in $10.87 and calculate 5.56% of that. You read in $10.00 and calculate 5% of that.

In the future, don't do all of this at once. You need to isolate the error and isolate each task. That means you start by not doing any calculations until you've proved to yourself that you can read in, read out, and display the data perfectly. Then you tackle calculations and stuff like that.

Okay. I've given you're errors a try the last few hours but am still stumped.
Specifically, it is that there are no syntax errors now, but the program doesn't work as it should. It is supposed to print employee data, but only prints zeros. Below are my code and input file, for you to see:

Code: http://pastebin.com/m897b9aa
Input: http://pastebin.com/m20f14b82

Any ideas where I go wrong?

You need to make sure the data is getting into the variables you want to from the file. You have 1's and 2's all over the place, but you have fin and fin1 instead of fin1 and fin2, so I see these functions/variables where I expect everything to be 1 or everything to be 2 and they're mixed, so it's really hard to make sense of:

void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);

It adds one more level of confusion,a s does the fact that you appear to have one input file, but two ifstream objects? Why? It just makes it harder to grasp the program logic. You've also made fin, fin1, fout1, and fout2 global variables, so you don't need to pass them at all. Making them global doesn't cause problems though.

Here's the solution, or at least an approach. One, change every variable instance called fin1 to fin2, then change every variable called fin to fin1. That way everything's consistent. Get the 1's together, get the 2's together. the compiler couldn't care less, but we humans do.

You must find out for sure whether your data is reading correctly all over the place. At the very end of every single read function, do the following (you'll take these out later):


  1. Add cout statements that display every variable that was just read in, each on a new line.
  2. Add the line cin.get () at the very end of the function. This pauses for input from you. Read each line. make sure that it is perfect. If not, debug. Everything else is completely irrelevant until you're positive you have good input. Hit the return key to get past the cin.get () line. This is debugging code. Delete it later when it's debugged.
  3. Do the exact same thing in main when you get BACK from the function. Those values had better still be in the variables.

Here's your main problem. See 2 and 3 above. Even if 2's perfect, 3 won't be. Why? Look at your Read function:

void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name);

No &'s next to the variables except for fin1. Hence you're passing the variables by value, not by reference. Hence they're local variables that go out of scope when the function ends. Hence you can't use them when you get back to main.

This function does nothing but read in data and throw it away:

void Read_Data_2 (ifstream &fin1, int skill, int benefitType, double contPercent, double hours, double taxID, string name)
{
        fin1 >> skill >> benefitType >> contPercent >> hours >> taxID;
        getline(fin1, name);
}

Set aside this program, google "pass by value" versus "pass by reference" in C++ and run some sample programs, then come back to this program and fix it. Long story short, you need an ampersand before all the variable names in these functions. I'm not guaranteeing there aren't more problems, but this is a massive one, luckily very easy to fix.

Good luck. I can't spend any more time on this.

It all came to to a few missing ampersands and variables, and a few misplaced calls.

Thanks so much for all of your help.

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.