OPTIMUS999 0 Newbie Poster

I have a payroll program that I been working on for a while and I gotten my code written. Yet, when I compile the program it keep giving me erros and I can't figure out why. I wonder is there anyone out there can tell me why I keep getting errors like C2059, C2065, C2143, and C2562. Here the program details:

Modularize the program:

* Use following modules or functions:

o main() – calls other functions
o getInput() – accepts and validates data, stores valid data in an employee array
o doCalculations() – performs calculations and accumulates totals
o performSorting() – sorts employee array into ascending sequence
o displayEmployeeResults() – display employee records from the sorted array
o displayPayrollSummaryResults() – display summary totals and averages

* Include function prototypes.
* Do not use any global variables.

Our client now has several employees, therefore, program must prompt keyboard operator to determine whether there is another employee to be processed, if not, display results (see output section below) and terminate program; otherwise prompt user and accept input data for next employee.


Processing:

1. See C++ Project #2 for calculations and validation requirements.

2. The keyboard entry character “y” or “Y” indicates that there is another employee to be processed; any other character indicates that there are no additional employees to be processed.

3. While processing payroll information for each employee, accumulate the following:

§ totalEmployees – the total number of employees processed

§ totalGrossPay – summation of all employees’ gross pay

§ totalNetPay – summation of all employees’ net pay

Output:

1. NOTE: This requirement requires the use of array(s). After all employee records have been processes, display the following payroll information for each employee, in ascending order by empID:

§ empID

§ payrollType

§ hoursWorked

§ payRate

§ regularPay

§ overtimePay

§ grossPay

§ stateTax

§ federalTax

§ totalTax

§ unionDues

§ netPay

2. After completinmg Step 1 above, display the following:

§ total number of employees

§ total gross pay

§ total net pay

§ id number and gross pay of employee with highest gross pay

§ id number and gross pay of employee with lowest gross pay

§ average gross pay – total gross pay divided by total number of employees

§ average net pay – total net pay divided by total number of employees

Special Instructions:

* Use while or do-while loop to determine when user has entered all records.
* Program must be properly documented throughout.

This is the code that I written:

//

#include "stdafx.h"
#include <iostream>


using namespace std;
using std::cout;
using std::cin;
using std::endl;


int _tmain(int argc, _TCHAR* argv[])
{


	
	// Declaring Function Prototypes
	void getInput (int [], char[], double[], double[], double[], int[], int[], int);

	void doCalculations (double [], double[], double[], double[], double[], double[],
		 double[], double[],double[],double[], int[], double[], double[], int);


	void performSorting (int [], double [], double[], double[], double[], double[], double[],
		 double[], double[],double[],double[], int[], int);


	void displayEmployeeResults (int [], char[], double [], double[] , double[], double[], double[], double[],
		 double[], double[],double[],double[], int[], double[], double[], int);

    void displayPayrollSummaryResults (int[], double[], double[], int[], double[], int);

	const static int Worker= 10;

	// Declaring Array Variable 

		int empID[Worker] = {};
		char payrollType[Worker] = {};
		double hoursWorked[Worker] = {};
		double payRate[Worker] = {};
		int unionCode[Worker] = {};
		double overtimePay[Worker] = {};
		double grossPay[Worker] = {};
		double stateTax[Worker] = {};
		double federalTax[Worker] = {};
		double totalTax[Worker] = {};
		double unionDues[Worker] = {};
		double netPay[Worker] = {};
		double regularPay[Worker] = {};
		int totalEmployees[1] = {};
		double totalGrossPay[1] = {};
		double totalNetPay[1] = {};

	std::cout << "\n Welcome to the Payroll Program!" << endl;

	//Calling getInput() by passing parameters
	getInput (empID, payrollType, hoursWorked, payRate, unionDues, unionCode, totalEmployees, Worker);
	
	// Calling doCalculations() by passing parameters 
	doCalculations (overtimePay, grossPay, stateTax, federalTax, totalTax, unionDues, netPay, regularPay,
				   hoursWorked, payRate, unionCode, totalGrossPay, totalNetPay, Worker);

	// Sorting employee data by Bubble sort function 
	performSorting (empID, overtimePay, grossPay, stateTax, federalTax, totalTax, unionDues, netPay, regularPay,
				    hoursWorked, payRate, unionCode, Worker);

	// Passing parameters to call for displayEmployeeResults
	displayEmployeeResults (empID, payrollType,hoursWorked, payRate, regularPay, overtimePay,grossPay, stateTax,
						   federalTax, totalTax, netPay, unionDues, totalEmployees, totalGrossPay, totalNetPay, Worker);

	// Passing parametrs to call for displayPayrollSummaryResults
	displayPayrollSummaryResults (totalEmployees, totalGrossPay,  totalNetPay, empID, grossPay, Worker);

} // End Main


	// getInput function declaration

	void getInput (int empID[],char payrollType[], double hoursWorked[],double payRate[],
			      double unionDues[], int unionCode[], int employees[], int Worker)

	//Displaying the input from User
			
	
	{	
		// Variable declarations
		int ID = 0;
		int employeeCount = 0;

		std::cout << "\n Enter your employee ID (100 - 800) #: ";
		std::cin >> empID [ID];
		
		//Using while loops to validate data inputted by User

			while (empID [ID] < 100 || empID [ID] > 800)
			{
				std::cout << "\n Please enter a correct employee ID!";
				std::cout << "\n Enter your employee ID (100 - 800) #: ";
				std::cin >> empID [ID];
			}

			std::cout << "\n Enter your payroll type (H or h for hourly employee): ";
			std::cin >> payrollType[ID] ;

		//Using while loops to validate data inputted by User
			while (payrollType [ID] != 'H' && payrollType [ID] != 'h')
			{
				std::cout << "\n Please enter a correct payroll type!";
				std::cout << "\n Enter your payroll type (H or h for hourly employee): ";
				std::cin >> payrollType [ID];
			}

		//Using while loops to validate data inputted by User
			std::cout << "\n Enter your hours worked (0 - 60.0): ";
			std::cin >> hoursWorked [ID];

		//Using while loops to validate data inputted by User
			while (hoursWorked [ID] < 0 || hoursWorked [ID] > 60.00)
			{
				std::cout << "\n Please enter a correct number of hours worked!";
				std::cout << "\n Enter your hours worked (0 - 60.0): ";
				std::cin >> hoursWorked [ID];
			}	
			
			std::cout << "\n Enter your pay rate (8.50 - 45.00): $";
			std::cin >> payRate [ID];

	//Using while loops to validate data inputted by User
			while (payRate [ID] < 8.50 || payRate [ID] > 45.00)
			{
				std::cout << "\n Please enter your correct pay rate!";
				std::cout << "\n Enter your pay rate (8.50 - 45.00): $";
				std::cin >> payRate [ID];
			}

			std::cout <<"\n Enter your union code (1 - 3): ";
			std::cin >> unionCode [ID];

	//Using while loops to validate data inputted by User
			while (unionCode [ID] != 1 && unionCode [ID] != 2 && unionCode [ID] != 3)
			{
				std::cout << "\n Please enter a correct union code!";
				std::cout <<"\n Enter your union code (1 - 3): ";
				std::cin >> unionCode [ID];
			}


		// Asking the user if there are more workers to be entered
		char response;
		std::cout << "\n Would you like to process another employee (Y or y for yes): ";
		std::cin >> response;
		
		// Setting up a counter and declaring variables
			ID++;
			employeeCount++;

		//Using while function to validate data
			while (response != 'Y' && response != 'y')
			{
				std::cout << "\n Do you have any other employees to be processed";
				employees[0] = employeeCount++;

			}

}//End function
	


	// doCalculation() function declaration

	void doCalculations (double overtimePay[], double grossPay[], double stateTax[], double federalTax[], double totalTax[],      
		                double unionDues[], double netPay[], double regularPay[],double hoursWorked[], double payRate[], int unionCode[],
					    double totalGrossPay[], double totalNetPay[], int Worker)

	{
	// Declaration of Variables
		double totalGross = 0;
		double totalNet = 0;


	for(int ID = 0; ID < 10; ID++)

	
	//Calculation of Overtime Pay and Regular Pay using if/else statement
	{
	if (hoursWorked [ID] > 40)
			{
				regularPay [ID] = payRate [ID] * 40;
				overtimePay [ID] = 1.5 * payRate [ID] * (hoursWorked [ID] - 40.0);
				grossPay [ID] = regularPay [ID] + overtimePay [ID];
			}

	//Calculation of Regular Work Pay
	else if (hoursWorked [ID] <=  40)
		{
			regularPay [ID] = payRate [ID]  * hoursWorked [ID];
		    overtimePay [ID] = 0;
			grossPay [ID] = regularPay [ID];
		}
	
	

	//Determination of State Tax Rate using if else statement
	{

	if (grossPay [ID] < 500)
		{
			stateTax [ID] = 0;
			
		}
		
		else if ( grossPay [ID] >= 500 && grossPay [ID] <= 1000)
		{
			stateTax [ID]= 0.03 * grossPay [ID];
				
		}
			
	    else if ( grossPay [ID] > 1000)
		{
		
			stateTax [ID] = 0.05 * grossPay [ID];
					
		}
	}//End if/else statement
	

		
	//Determination of Federal Tax Rate using if else statement
	{

		if ( grossPay [ID] < 500)
		{
			federalTax [ID] = 0;
		
		}
			
		else if (grossPay [ID] >= 500 && grossPay [ID] <= 1000)
		{
			federalTax [ID] = 0.05 * grossPay [ID];
		
		}
		
		else if (grossPay [ID] > 1000)
		{
			federalTax [ID] = 0.07 * grossPay [ID];
		
		}
	}
	

	}//End if/else statement

	


		// Calculation of Total Tax and Net Pay 
		for(int ID = 0; ID < 10; ID++)
		totalTax [ID] =  stateTax [ID] + federalTax [ID];

		
		//Calculation of Net Pay
		for(int ID = 0; ID < 10; ID++)
		netPay [ID] = grossPay [ID] - (stateTax [ID] + federalTax [ID] + unionDues [ID]);

		// Calculation of Total Gross Pay and Total Net Pay
		
		//Declaring Variables for Array
		totalGrossPay[0] = totalGross;
		totalNetPay[0] = totalNet;
		
		for(int ID = 0; ID < 10; ID++)
		{
			totalGross = totalGross + grossPay[ID];
			totalNet = totalNet + netPay[ID];
		}
							
	}//end function

	
	void performSorting (int empID[], double overtimePay[], double grossPay[], double stateTax[],
					    double federalTax[], double totalTax[],double unionDues[], double netPay[],
					    double regularPay[],double hoursWorked[], double payRate[], int unionCode[], int Worker)

	{
		
	
	// Bubble Sort function for empID
	int hold;
	double temp;

	for (int pass = 0; pass < 10-1; pass++)

	{
		for(int j = 0; j < 10-1; j++)
						
		{

			if(empID[j] > empID[j + 1])
							
			{
								
				hold = empID[j];
				empID[j] = empID[j + 1];
				empID[j + 1] = hold;
							}

						}
			}

	// Bubble Sort function for overtimePay
	for (int pass = 0; pass < 10-1; pass++)
						
	{
		for(int j= 0; j < 10-1; j++)
		
		{
			if(overtimePay[j] > overtimePay[j + 1])
			temp = overtimePay[j];
			overtimePay[j] = overtimePay[j + 1];
			overtimePay[j + 1] = temp;
		}
	
	}
	

	// Bubble Sort Algorithm for grossPay
	for (int pass = 0; pass < 10-1; pass++)
	{
		for(int j= 0; j < 10-1; j++)
		
		{

			if(grossPay[j] > grossPay[j + 1])
			{
				temp = grossPay[j];
				grossPay[j] = grossPay[j + 1];
				grossPay[j + 1] = temp;

			}
		}
									
	}

	// Bubble Sort function for stateTax
	for(int pass = 0; pass < 10-1; pass++)
	{

	  for(int j= 0; j < 10-1; j++)
	{

		if(stateTax[j] > stateTax[j + 1])
	{
			temp = stateTax[j];
			stateTax[j] = stateTax[j + 1];
		    stateTax[j + 1] = temp;
		}
	  }

	}

	// Bubble Sort function for federalTax
	for(int pass = 0; pass < 10-1; pass++)
	{
		for(int j= 0; j < 10-1; j++)
	{
		if(federalTax[j] > federalTax[j + 1])
		{
			temp = federalTax[j];
			federalTax[j] = federalTax[j + 1];
			federalTax[j + 1] = temp;
			}
	}
	}

	// Bubble Sort Algorithm for totalTax
	for(int pass = 0; pass < 10-1; pass++)
	{

	for(int j = 0; j < 10-1; j++)
	{

	if(totalTax[j] > totalTax[j + 1])
	{
			temp = totalTax[j];
			totalTax[j] = totalTax[j + 1];
		    totalTax[j + 1] = temp;
	}
		}
	}

// Bubble Sort Algorithm for unionDues
   for(int pass = 0; pass < 10-1; pass++)
{

	for(int j= 0; j < 10-1; j++)
{

	if(unionDues[j] > unionDues[j + 1])
{
		temp = unionDues[j];
		unionDues[j] = unionDues[j + 1];
		unionDues[j + 1] = temp;
	}
		}
}

// Bubble Sort function for netPay
												
   for(int pass = 0; pass < 10-1; pass++)
													
   {
		for(int j= 0; j < 10-1; j++)
															
	   {

		if(netPay[j] > netPay[j + 1])
																	
		   {
																		
			   temp = netPay[j];
			   netPay[j] = netPay[j + 1];
			   netPay[j + 1] = temp;
																	
		   }
															
	   }
													
   }

												
   // Bubble Sort function for regularPayAr
												
   for(int pass = 0; pass < 10-1; pass++)
													
   {

	 for(int j= 0; j < 10-1; j++)
														
	   {
			if(regularPay[j] > regularPay[j + 1])
															
		   {
																
			   temp = regularPay[j];
			   regularPay[j] = regularPay[j + 1];
			   regularPay[j + 1] = temp;
															
		   }
														
	   }
													
   }

												
   // Bubble Sort function for hoursWorked
												
   for(int pass = 0; pass < 10-1; pass++)
													
   {
       for(int j= 0; j < 10-1; j++)
												
	   {
			if(hoursWorked[j] > hoursWorked[j + 1])
															
		   {
																
			   temp = hoursWorked[j];
			   hoursWorked[j] = hoursWorked[j + 1];
			   hoursWorked[j + 1] = temp;
			}
												
	   }
												
   }

												
   // Bubble Sort function for payRate
											
   for(int pass = 0; pass < 10-1; pass++)
													
   
   {
		for(int j= 0; j < 10-1; j++)
														
	   {
		
		   if(payRate[j] > payRate[j + 1])

		{
																	
			temp = payRate[j];
			payRate[j] = payRate[j + 1];
			payRate[j + 1] = temp;
																
		   }
														
	   }
													
   }

  // Bubble Sort function for unionCode
	for(int pass = 0; pass < 10-1; pass++)
			
{

	for(int j= 0; j < 10-1; j++)
														
	{

														
		if(unionCode[j] > unionCode[j + 1])
															
		{
																
			hold = unionCode[j];
			unionCode[j] = unionCode[j + 1];
			unionCode[j + 1] = hold;
															
		}
														
	}
													
	}

	}// end function



	//Declaration for displaying displayEmployeeResults
	
	void displayEmployeeResult (int empID[], char payrollType[], double hoursWorked[], double payRate[], double regularPay[], double overtimePay[],
					           double grossPay[], double stateTax[], double federalTax[], double totalTax[],double netPay[], double unionDues[],
							   int totalEmployees[], double totalGrossPay[], double totalNetPay[], int data [], int UnionCode [], int Worker)
	{
			
            		
					 
			
		 //Output from employee
			
		 std::cout << "\n_______________________________" << endl;
		
		  for(int ID = 0; ID < Worker; ID++)
		  {

		 std::cout << "Payroll results for Worker #: " << data[ID];
		 
		 std::cout << "\n Your employee ID # is: " << empID [ID];
		
		 std::cout << "\n Your payroll type is: " << payrollType [ID];
		
		 std::cout << "\n Your hours worked: " << hoursWorked [ID];
	    
		 std::cout << "\n Your pay rate is: $" << payRate [ID];
		
		 std::cout << "\n Your regular pay is: $" << regularPay [ID];

		 std::cout << "\n Your overtime pay is: $" << overtimePay [ID];
	
		 std::cout << "\n Your gross pay is: $" << grossPay [ID];
		
		 std::cout << "\n Your state tax is: $" << stateTax [ID];
			
		 std::cout <<"\n Your federal tax is: $" << federalTax [ID];

		 std::cout << "\n Your total tax is: $" << totalTax [ID];

		 std::cout << "\n Your net pay is: $" << netPay [ID];

		 //Detrmination of Union Due
		switch (unionCode [ID])
		 {
	
		case 1: 
			unionDues [ID] = 15.00;
			std::cout << "\n Your union dues is: $" << unionDues [ID] << endl;
			break;

		case 2:
			unionDues [ID] = 25.00;
			std::cout << "\n Your union dues is: $" << unionDues [ID] << endl;
			break;

		case 3:
			unionDues [ID] = 35.00;
			std::cout << "\n Your union dues is: $" << unionDues [ID] << endl;
			break;

			default: 
			unionDues  [ID] = 0.00;
			std::cout << "\n Your union dues is: $" << unionDues [ID] << endl;
			break;
		
		
		} //end switch
		  }
	

	



		

	// Function declaration for displayPayrollSummaryResults
	void displayPayrollSummaryResults (int totalEmployees[], double totalGrossPay[], double totalNetPay[], 
									  int empID[], double grossPay[], int Worker);
	{


						
	// Display a summary of employee information
		std::cout << "Total number of Employees entered:"<< totalEmployees[0] << endl;

		std::cout << "Total gross pay of Employees:"<< "$"<< totalGrossPay[0] << endl;
						
		std::cout << "Total Net pay of Employees:"<< "$"<< totalNetPay[0] << endl;
						
		std::cout << "Average Gross pay of Employees is:"<< "$"<< totalGrossPay[0]/ totalEmployees[0] << endl;
		
		std::cout << "Average Net pay of Employees is:"<< "$"<< totalNetPay[0]/ totalEmployees[0] << endl;
		
	

	// Calculates employee with highest grosspay
		//Declaring Variables for Payroll Summary
			
			int maxEmpID = empID[0];
			double maxGrossPay = grossPay[0];
			int minEmpID = empID[0];
			double minGrossPay = grossPay[0];
			int empIndex = 0;
			int count = 0;
			int count2 = 0;
			int minGrosspay = 0;				
		
		for(count = 1; count < Worker; count++)			
		{
							
			if(empID[count] > maxEmpID)
							
			{
								
				maxEmpID = empID[count];

						
			}
						
		
		}				
		
		std::cout << "Employee with highest gross pay is employee ID:" << maxEmpID << "\n";


						
		// Calculates employee with highest grosspay
						
		for(count2 = 1; count2 < Worker; count2++)
						
		{
							
			if(grossPay[count2] > maxGrossPay)
							
			{
								
				maxGrossPay = grossPay[count2];

						
			}

						}
						
		std::cout << "With the gross pay of:" <<  "$" << maxGrossPay;
		
						
	// Calculates employee with lowest grosspay
						
			for(count = 1; count < Worker; count++)
							
			{
							
				if(empID[count] < minEmpID)
								
				{
									
					minEmpID = empID[count];

								}
							}
						
			std::cout << "Employee with lowest gross pay is employee ID:" << minEmpID << "\n";

						
	// Calculates employee with highest grosspay
												
			for(count2 = 1; count2 < Worker; count2++)
												
			{
													
				if(grossPay[count2] < minGrossPay)
													
				{
														
					minGrossPay = grossPay[count2];

													
				}

												
			}
												
			
			std::cout << "With the gross pay of:" << "$" << minGrossPay;

							
			for(count2 = 1; count2 < Worker; count2++)
							
			{
								
				if(grossPay[count2] > minGrossPay)
									
				{
										
					maxGrossPay = grossPay[count2];
										
					empIndex++;
									}


							}


		std::cout << "Employee with highest gross pay is employee ID:" << empID[empIndex] << "\n";
		std::cout << empIndex << endl;
		std::cout << "With the gross pay of:" << "$" << minGrossPay;

		}//End Function

		
		

		
		system("PAUSE"); // system pauses so user can see outcome on the screen
		return 0;

		}

}

}