Thread: Trying to create a payroll calculation program

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    8

    Trying to create a payroll calculation program

    I am trying to create a Payroll Calculation program that will calculate an employees hourly pay on a weekly
    basis; including overtime, payroll deductions (federal, state, local taxes, medical insurance deductions), etc...

    I am pretty new to programming and need some help with this. I have included the code that I have done but am not sure if I am coding this correctly.

    I am trying to create it so that the main will only control execution statements and supporting function calls. Could someone please help me with this program?

    Code:
    #include<iostream>
    #include<string>
    
    using namespace std;
    
    
    
    double OvertimeHours [2];
    double HourlyPayRate ;
    double OvertimePay;
    double GrossPay;
    const double StateTax = .30;			//30% State Tax Rate
     
    
    int main()
    {
    	int EmployeeID;
    
    	void HourlyPayRate(double hours; double rate)
    	void 
    	
    
    	int MaritalStatus;
    	
    
    /**************************************************************************************************/
    //Determines the Marital Status of Employees
    	switch(MaritalStatus)
    	{
    	case 'M':
    	case 'm':
    		cout<< "Married";
    		break;
    	case 'S':
    	case 's':
    		cout<< "Single";
    		break;
    	default:
    		cout << "Unknown Selection!\n"
    			 << "Choose Again.\n";
    	}
    /**************************************************************************************************/
    	if (MaritalStatus == 'M' || 'm')
    	{
    		FedTax = .15 * GrossPay;			//15% federal income tax for married employees
    		GrossPay = GrossPay - 18.00;		//$18.00 medical insurance deduction
    
    	else 
    		if (MaritalStatus == 'S' || 's')	
    		FedTax = .20 * GrossPay;			//20% federal income tax for single employees
    		GrossPay = GrossPay - 10.00;		//$10.00 medical insurance deduction
    
    
    
    /**************************************************************************************************/
    //This function will calculate the hourly wage
    void HourlyPayRate()
    {
    	double hours = 0;
    	double rate = 0
    
        cout << endl << Number of Hours Worked:   ";
    	cin >> hours;
        
    	cout << endl << "Pay Per Hour is:     ";
    	cin >> rate;
    	cout << endl;
    
    	if (hours <= 40)
    	{
    		hours = (rate * hours);
    		cout << endl << setiosflags(ios::fixed) << setprecision (2)
    			 << "The hourly worker's weekly gross is: $" << hours << endl;
    
    		return;
    	}
    	
    	if (hours > 40)
    	{
    		hours = (rate * 40) + ((rate * 1.5) * (hours - 40));
    		cout << endl << setiosflags(ios::fixed) << setprecision (2)
    			 << "The hourly worker's weekly gross is: $" << hours << endl;
    
    		return;
    	}
    
    	else
    	{
    		cout << endl << "Data Entry Not Valid, Please Reenter Data." << endl;
    
    		return;
    	}
    	return;
    }
    Is there a better way to achieve my goal? I am not sure but it seems as though my code is out of place. Should I continue on with the way I am coding or should I use object oriented programming to create my program? if I should then how so? I am so confused

  2. #2
    I really just glanced through it but here are some things.

    Some of your if statements need to have braces around them. const double StateTax = .30 could be expressed as .3 instead since it is the same thing (it could also be a float). Your return statement has no parameters (put "return(0);" or "return 0;").

    Like i said before I just quickly glanced at it; I am in a hurry to get to the dinner table. Oh and when you are includinn your needed files I find it easier to understand if you put a space between #include and <file.to.include>.

    Oh, and bold is a little hard to read.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. a phone book program
    By mackieinva in forum C Programming
    Replies: 2
    Last Post: 09-19-2007, 06:31 AM
  2. How to create a file association program?
    By eShain in forum Windows Programming
    Replies: 1
    Last Post: 03-06-2006, 12:15 PM
  3. Program calculation problems?
    By rebel in forum C++ Programming
    Replies: 7
    Last Post: 11-28-2005, 03:31 PM
  4. help with accumulating in payroll program
    By indigo0086 in forum C++ Programming
    Replies: 6
    Last Post: 10-15-2002, 09:11 PM
  5. program won't create status bar
    By Unregistered in forum Windows Programming
    Replies: 7
    Last Post: 08-30-2001, 04:00 PM