c++ Payroll Due Today!!!!

This is a discussion on c++ Payroll Due Today!!!! within the C++ Programming forums, part of the General Programming Boards category; I have a payroll program due today and i cant figure out why I'm getting multiple errors, including an error ...

  1. #1
    Registered User
    Join Date
    Feb 2010
    Posts
    1

    c++ Payroll Due Today!!!!

    I have a payroll program due today and i cant figure out why I'm getting multiple errors, including an error in my iostream which has not been edited. please help! here are the codes for the .cpp and the .h files. the compfun.cpp in the cpp file is just for the rounding function. I havent finished typing it but after building it this far i thought it would be a good idea to address the issues now instead of later when there is more problems. Thanks!

    .cpp first:
    Code:
    #include "weeklyEMP.h"
    #include <iostream>
    #include <string>
    #include "compfun.cpp"
    using namespace std;
    
    const double WEEKLY_ALLOWANCE = 39.42; 
    const double FICA_TAX_RATE = 0.0765; 
    
    weeklyEMP::weeklyEMP()
    {
    	initName = "";
    	initHours = 0.0;
    	initRate = 0.0;
    	initExemptions = 0;
    	initFilingStatus = "";
    }
    weeklyEMP::weeklyEMP(string initName, double initHours, double initRate, int initExemptions, string initFilingStatus)
    {
    	my_name = initName;
    	my_hours = initHours;
    	my_rate = initRate;
    	my_exemptions = initExemptions;
    	my_filingStatus = initFilingStatus;
    }
    
    void weeklyEMP::set_hours(double thisWeeksHours)
    {
    	my_hours = thisWeeksHours;
    } 
    void weeklyEMP::set_rate(double thisWeeksRate)
    {
    	my_rate = thisWeeksRate;
    }
    weeklyEMP::double grossPay() const;
    {
    	if(my_hours <=40)
    	return my_hours * my_rate; 
    	else 
    	return (40*my_rate) + (my_hours-40) * 1.5 * my_rate;
    }
    weeklyEMP::double incomeTax() const;
    { 
    double result(0.0); 
    double taxableIncome(grossPay() - my_exemptions * WEEKLY_ALLOWANCE); 
    
    if(my_filingStatus == "S" || my_filingStatus == "s") 
    { 
    if (taxableIncome <= 23.00) 
    result = 0.00; 
    else if(taxableIncome <= 397.00) 
    result = 0.15 * (taxableIncome - 23.00); 
    else if(taxableIncome <= 928.00) 
    result = 56.10 + 0.28 * (taxableIncome - 397.00); 
    else if(taxableIncome <= 2121.00) 
    result = 204.78 + 0.33 * (taxableIncome - 928.00); 
    else 
    result = 598.47 + 0.28 * (taxableIncome - 2121.00); 
    } 
    
    if(my_filingStatus == "M" || my_filingStatus == "m") 
    { 
    if(taxableIncome <= 65.00) 
    result = 0.00; 
    else if(taxableIncome <= 689.00) 
    result = 0.15 * (taxableIncome - 65.00); 
    else if(taxableIncome <= 1573.00) 
    result = 93.60 + 0.28 * (taxableIncome - 689.00); 
    else if(taxableIncome <= 3858.00) 
    result = 341.12 + 0.33 * (taxableIncome - 1573.00); 
    else 
    result = 1095.17 + 0.28 * (taxableIncome - 3858.00); 
    } 
    
    result = round(result, 2);  
    
    return result; 
    }
    double FICATax() const;
    {
    	return grossPay() * FICA_TAX_RATE; 
    }
    string name() const;
    {
    	return my_name();
    }



    That is all i have so far for the .cpp. Here is the .h file


    Code:
    #ifndef weeklyemp_H   // Avoid redeclaring class bankAccount.
    #define weeklyemp_H   // This code is compiled only once
    #include <string>    // for class string
    using namespace std;
    class weeklyEmp
    {
    public:
    	weeklyEmp();
    	weeklyEmp(string initName, double initHours, double initRate, int initExemptions, string initFilingStatus);
    	void set_hours(double thisWeeksHours);
    	void set_rate(double thisWeeksRate);
    	double grossPay() const;
    	double incomeTax() const;
    	double FICATax() const;
    	string name() const;
    
    private:
    	string my_name;
    	double my_hours;
    	double my_rate;
    	int my_exemptions;
    	string my_filingStatus;
    	
    
    }
    #endif

    this file should be done right now but is still comming up with errors. some are syntex, some say weeklyEMP is not a class, it just seems that the .cpp file isnt loading the .h file. any suggestions?

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,594
    You forgot the terminating semi-colon for your class definition.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    Probably not related to your errors, but you should never put using namespace declarations in your header files -- only in .cpp files.
    Since you're including your "weeklyEMP.h" before the standard header files, all other header files below it are also using namespace std whether they want to or not, which could cause all kinds of bad things to happen.
    "I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008

    "the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Yesterday, Today and Tomorrow
    By happyclown in forum A Brief History of Cprogramming.com
    Replies: 6
    Last Post: 01-29-2009, 07:36 AM
  2. what happened to the function today
    By yes in forum C++ Programming
    Replies: 6
    Last Post: 02-03-2006, 07:05 AM
  3. C program for Class --- DUE TODAY!!! AHHHH
    By Fr0st2k in forum C Programming
    Replies: 6
    Last Post: 09-22-2004, 03:10 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21