Thread: Help with Tax calculator program

  1. #1
    Registered User
    Join Date
    Apr 2006

    Help with Tax calculator program

    How do i change this to input files or a struct to enter a series of data to the program. I am fine with doing programs asking for input. I get confused on the struct parts. Please help me thru this. It is driving me nuts.

    #include <iostream>
    #include <iomanip>
    using namespace std;
    struct Employee
    	int employeeID, numDependent;
    	double grossPay, netPay,
    		   cityTax, fedTax, 
    		   cityTaxToDate, fedTaxToDate,
    		   payRate, hourWorked;
    struct Tax
    	double city;
    	double fed;
    void calculateTaxes(Tax &, Employee *, int const);
    void main()
    	int const numEmployee = 3;
    	Tax rate; = 1.15;
    	rate.fed = 20;
    	Employee test[numEmployee];
    	for(int i=0; i < numEmployee; i++)
    		cout<<"\nEnter employee ID: ";
    		cout<<"Enter the number of dependents: ";
    		cout<<"Enter pay rate: ";
    		cout<<"Enter the hours worked: ";
    		cout<<"Enter city tax withheld to date: ";
    		cout<<"Enter federal tax withheld to date: ";
    		cout<<"Enter gross pay to date: ";
    	calculateTaxes(rate, test, numEmployee);
    	cout<<setw(10)<<"\nemployee ID"<<setw(10)<<"gross pay"
    		<<setw(10)<<"net pay"<<setw(10)<<"city tax"
    		<<setw(13)<<"federal tax"<<setw(15)<<"total withheld"<<endl;
    	for(int j=0; j < numEmployee; j++)
    		cout <<setiosflags(ios::fixed | ios::showpoint)<<setprecision(2)
    			<<setw(15)<<(test[j].cityTaxToDate + test[j].fedTaxToDate)<<endl;
    void calculateTaxes(Tax &t, Employee *e, int const numE)
    	for(int i=0; i < numE; i++)
    		e[i].grossPay = (e[i].payRate)*(e[i].hourWorked);
    		if(e[i].grossPayToDate < 40000)
    			e[i].cityTax = (e[i].grossPay)*(;
    			e[i].cityTax = 0;
    		e[i].fedTax = (e[i].grossPay - 50*e[i].numDependent)*(t.fed/100);
    		e[i].netPay = e[i].grossPay - e[i].cityTax - e[i].fedTax;
    		e[i].cityTaxToDate = e[i].cityTaxToDate + e[i].cityTax;
    		e[i].fedTaxToDate = e[i].fedTaxToDate + e[i].fedTax;
    		e[i].grossPayToDate = e[i].grossPayToDate + e[i].grossPay;

  2. #2
    semi-colon generator ChaosEngine's Avatar
    Join Date
    Sep 2005
    Chch, NZ
    ok exactly what is causing you trouble?

    and please delete your other post.
    "I saw a sign that said 'Drink Canada Dry', so I started"
    -- Brendan Behan

    Free Compiler: Visual C++ 2005 Express
    If you program in C++, you need Boost. You should also know how to use the Standard Library (STL). Want to make games? After reading this, I don't like WxWidgets anymore. Want to add some scripting to your App?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sales tax
    By Mark_Guy in forum C Programming
    Replies: 0
    Last Post: 10-22-2008, 08:47 AM
  2. Big help for big program
    By Mahesh in forum C Programming
    Replies: 1
    Last Post: 05-04-2005, 10:02 AM
  3. multi file project error
    By dantestwin in forum C++ Programming
    Replies: 14
    Last Post: 07-22-2004, 12:10 AM
  4. Replies: 3
    Last Post: 11-03-2003, 08:55 PM
  5. Help with sample tax program
    By DaMonsta in forum C Programming
    Replies: 1
    Last Post: 05-15-2003, 03:45 AM