program won't compile?

This is a discussion on program won't compile? within the C++ Programming forums, part of the General Programming Boards category; Hey guys. Can you take a look at this program. It is suppose to calculate federal and city income taxes ...

  1. #1
    Registered User
    Join Date
    Feb 2006
    Location
    North Liberty, IA
    Posts
    67

    program won't compile?

    Hey guys. Can you take a look at this program. It is suppose to calculate federal and city income taxes withheld for a certain pay period. I use a function to calculate this. It keeps telling me that I have too many intitializers and that my function calculateTaxes uses 'void' illegally. Any help is grealty appreciated.

    Code:
    #include <iostream>
    #include <cmath>
    #include <string>
    #include <iomanip>
    using namespace std;
    
    void calculateTaxes(int depends, 
    		double payGross, 
    	                double& cityTaxDate,
    		double& fedTaxDate, 
    		double& payNet,
    		double& withheldCityTax, 
    		double& withheldFedTax);
    
    
    
    int main()
    {
    	cout << "This program calculates taxes withheld from a weekly paycheck.\n\n";
    
    for(;;)
    {
    	
    	
    
    	cout << "Please enter your employee number (-1 to quit).\n\n";
    	int empNumber;
    	cin >> empNumber;
    
    	if(empNumber < 0)break;
    
    	cout << "Please enter your number of dependents.\n\n";
    	int dependents;
    	cin >> dependents;
    
    	cout << "Please enter your hourly pay rate.\n\n";
    	double payRate;
    	cin >> payRate;
    
    	cout << "Please enter the amount of city income tax withheld to date.\n\n";
    	double cityTaxToDate;
    	cin >> cityTaxToDate;
    
    	cout << "Please enter the amount of federal income tax withheld to date.\n\n";
    	double fedTaxToDate;
    	cin >> fedTaxToDate;
    
    	cout << "Please enter the number of hours worked this week.\n\n";
    	double hoursWorked;
    	cin >> hoursWorked;
    
    	double grossPay = payRate * hoursWorked;
    
    	double cityTaxWithheld = 0;
    	double fedTaxWithheld = 0;
    	double netPay = 0;
    	
    
    	void calculateTaxes(dependents, grossPay, cityTaxToDate, 
    						 fedTaxToDate, netPay, cityTaxWithheld, fedTaxWithheld);
    
    	cout << "Employee Number: " << empNumber << "\n\n"
    		 << "Gross Pay: $" << setprecision(3) <<  grossPay << "\n\n"
    		 << "Net Pay: $" << setprecision(3) << netPay << "\n\n"
    		 << "Amount of City Income Tax Withheld: $" << setprecision(3) << cityTaxWithheld << "\n\n"
    		 << "Amount of Federal Income Tax Withheld: $" << setprecision(3) << fedTaxWithheld << "\n\n"
    		 << "Amount of City Income Tax Withheld to Date: $" << setprecision(3) << cityTaxToDate << "\n\n"
    		 << "Amount of Federal Income Tax Withheld to Date: $" << setprecision(3) << fedTaxToDate << "\n\n" << endl;
    }
    return 0;
    }
    
    
    
    
    void calculateTaxes(int depends, 
    		double payGross, 
    		double& cityTaxDate,
    		double& fedTaxDate, 
    		double& payNet,
    		double& withheldCityTax, 
    		double& withheldFedTax)
    {
    	
    	if( cityTaxDate < 460)
    		withheldCityTax = payGross * .0115;
    	else
    		withheldCityTax = 0;
    
    	cityTaxDate += withheldCityTax;
    
    	
    
    	withheldFedTax = ((payGross - (depends * 50)) * .2);
    
    	payNet = (payGross - (withheldCityTax + withheldFedTax));
    
    	fedTaxDate += withheldFedTax;
    
    	
    }

  2. #2
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,066
    Code:
    int main()
    {
           // Code...
    
           void calculateTaxes(dependents, grossPay, cityTaxToDate,
    						 fedTaxToDate, netPay, cityTaxWithheld, fedTaxWithheld);
           // Remove the void on the function call
    }
    Sent from my iPadŽ

  3. #3
    Registered User
    Join Date
    Feb 2006
    Location
    North Liberty, IA
    Posts
    67
    Thanks slymaelstrom. I think it is time for me to take a break after that one.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 01:42 AM
  2. Compile Public Domain Pocket PC C Program
    By m1l in forum Projects and Job Recruitment
    Replies: 2
    Last Post: 07-20-2007, 04:02 AM
  3. Using variables in system()
    By Afro in forum C Programming
    Replies: 8
    Last Post: 07-03-2007, 12:27 PM
  4. new to C--can't get program to compile
    By samerune in forum C Programming
    Replies: 12
    Last Post: 04-02-2007, 09:44 AM
  5. how do i compile a program that deals w/classes?
    By Shy_girl_311 in forum C++ Programming
    Replies: 5
    Last Post: 11-11-2001, 01:32 AM

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