Taxrate Payroll Program(Help Finding Error)

Pages: 12
Do I need to put ms in while(input>>employeeid>>hoursworked>>hourlyrate)?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <iostream>
#include <fstream>
using namespace std;
int main () {
    ifstream input;// Declare file streams.
    input.open("employee.txt"); //Open the input file
        int numberofemployees;
        int employeeid, hoursworked;
        char ms;
        float hourlyrate, grosspay, taxamount, netpay;
        float TAXRATE=0.20;
        numberofemployees=0;
        while(input>>employeeid>>hoursworked>>hourlyrate>>ms) {
        grosspay=hoursworked*hourlyrate;
        if( grosspay > 1000 )    TAXRATE=0.30;
              else if( grosspay > 800 ) TAXRATE=0.20;
              else if( grosspay > 500 ) TAXRATE=0.10;
              else TAXRATE = 0.0;
              switch(ms)
{
   case 'S': taxrate+=0.05;
   break;
   case 'M': taxrate+=0.10;
   break;
   default: taxrate+=0.20;
}
        taxamount=grosspay*TAXRATE;
        netpay=grosspay-taxamount;
        cout<<"EMPLOYEE ID IS " << employeeid<<endl;
        cout<<"THE HOURS WORKED ARE " << hoursworked<<endl;
        cout<<"THE HOURLY RATE IS " << hourlyrate<<endl;
        cout<<"THE GROSSPAY IS " << grosspay<<endl;
        cout<<"THE TAXAMOUNT IS " << taxamount<<endl;
        cout<<"THE NETPAY IS " << netpay<<endl<<endl;
        }//WHILE
        input.close();//Close the files
    system ( "pause" );
}//main()  
Figured it out. Thank you so much. I had to declare ms with a charr up top. Can i bother you for 1 more question?
K
The last thing I wanted to do:

Compute the overtime pay according to this:

Any hours over 40 are considered time and a half (overtime).
You may want to find overtime hours (e.g. hoursworked – 40) and overtime pay (e.g. overtimehours*hourlyrate * 1.5)

I have to compute the regularpay and overtimepay separately and add them to get the grosspay. How would that look in my program?
I know I need to put overtimehours and overtimepay with the int but it's an if statement correct?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include <iostream>
#include <fstream>
using namespace std;
int main () {
    ifstream input;// Declare file streams.
    input.open("employee.txt"); //Open the input file
        int numberofemployees;
        int employeeid, hoursworked;
        char ms;
        float hourlyrate, grosspay, taxamount, netpay, overtimepay=0;
        float TAXRATE=0.20;
        numberofemployees=0;
        while(input>>employeeid>>hoursworked>>hourlyrate>>ms) {
        grosspay=hoursworked*hourlyrate;
        if( grosspay > 1000 )    TAXRATE=0.30;
              else if( grosspay > 800 ) TAXRATE=0.20;
              else if( grosspay > 500 ) TAXRATE=0.10;
              else TAXRATE = 0.0;
              switch(ms)
{
   case 'S': taxrate+=0.05;
   break;
   case 'M': taxrate+=0.10;
   break;
   default: taxrate+=0.20;
}

        if(hoursworked>40){
              overtimepay = (hoursworked-40)*hourlyrate*1.5;
        }
        taxamount=grosspay*TAXRATE;
        netpay=grosspay-taxamount+overtimepay;
        cout<<"EMPLOYEE ID IS " << employeeid<<endl;
        cout<<"THE HOURS WORKED ARE " << hoursworked<<endl;
        cout<<"THE HOURLY RATE IS " << hourlyrate<<endl;
        cout<<"THE GROSSPAY IS " << grosspay<<endl;
        cout<<"THE TAXAMOUNT IS " << taxamount<<endl;
        cout<<"THE OVERTIMEPAY IS "<< overtimepay <<endl;
        cout<<"THE NETPAY IS " << netpay<<endl<<endl;
        }//WHILE
        input.close();//Close the files
    system ( "pause" );
}//main()  
In my program TAXRATE is declared so I just had to make taxrate uppercase. Figured it out. Thank you for all of the help. How long have you been programming C++?
Haha.. only 3 years..
welcome =)
3 weeks for me. Thank you for all of the help you've given me tonight though. Is there any way to add ya as a friend on a friend list on this website? Haha
Haha.. I am not sure! =) But, friend.. SURE!! Practise more, and you will GET it. =)
Thank ya Iwtan90. My name's Edward Michael Schugotti. Take it easy kid
Haha.. I am wilson!!
Hey Wilson I'm continuing to work on my Payroll Program and I have a question to ask you regarding it. Would you be able to help me later this evening? Around say 9PM E? Are you going to be around?
Topic archived. No new replies allowed.
Pages: 12