PAY ROLL PROBLEM!!

Hello..

Ok this is driving me nuts.. I made this pay roll program. It compiles great and functions well..

only one problem!

No matter want I do I can't the syntax to become readable.. This is my out put..
0x23d8284m4010
in my text file.. and just about the same on the screen. Can any body help me fix this problem. I need the output to be readable.

Here is my code
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
    #include <iostream>
    #include <fstream>
    #include <iomanip>

    using namespace std;
    class payroll{
     ofstream fin;
     char employeeid[100][12];
     char employeename[100][100];
     char maritalstatus;
     int hoursworked, overtime;
     float hourlyrate,overtimepay,regularpay,grosspay,taxrate,taxamount,netpay;
     void calculategrosspay();
     void calculatetax();
     void calculatenetpay();
     void printheadings();
     void printdata();
     
     
     public:payroll();
     ~payroll();
     void printreport();
     void start(); };
     
     void payroll::calculategrosspay(){
            if(hoursworked > 40){
            overtime = hoursworked - 40;
            regularpay = hoursworked * hourlyrate;
            overtimepay = overtime*(hourlyrate * 1.5);
            grosspay = regularpay + overtimepay; }
            else grosspay = hoursworked * hourlyrate; }
     void payroll::calculatetax(){
            if(grosspay >=500) taxrate = .30;
            else if(grosspay > 200.00) taxrate = .20;
            else taxrate =.10;
            if(maritalstatus == 'S'||maritalstatus =='s')
            taxrate = taxrate +.05;
            taxamount = grosspay*taxrate;}
     void payroll::calculatenetpay(){
     netpay = grosspay - taxamount; }
     void payroll::printheadings(){
            cout<<setw(45)<<"-Payroll Report-"<<endl;
            cout<<"--------------------------------------------------"<<endl;
            cout<<"Name     ID   HW OT RT-PAY OT-PAY GROSS"
            "Tax  Netpay"<<endl;
            cout<<"--------------------------------------------------"<<endl;
        }
        void payroll::printdata(){
        cout<<setprecision(2)<<setiosflags(ios::showpoint);
        cout<<setw(6)<<*(char*)&employeename<<setw(12)<<*(char*)&employeeid<<setw(4)
        <<*(int*)&hoursworked<<setw(3)<<*(int*)&overtime<<setw(8)<<*(float*)&regularpay<<setw(8)
        <<*(float*)&overtimepay<<setw(8)<<*(float*)&grosspay<<setw(8)<<*(float*)&taxamount<<setw(8)
        <<*(float*)&netpay<<endl;
           
        }          
       void payroll::start(){
            int counter=0;
            int NumberOfEmp;
            cout<<"Enter the number of Employees"; 
            cin>>NumberOfEmp;  
            while((((((((((counter<NumberOfEmp)&&(cout<<"Employee ID:")&&(cin>>employeeid[counter])&&(cout<<"Enter the Employee Marital Status: Entet S for single or M for Married ")&&(cin>>maritalstatus)&&(cout<<"Enter in Employee Full name:")&&(cin>>employeename[counter])&&(cout<<"Enter Hours worked:")&&(cin>>hoursworked)&&(cout<<"Enter in hourly rate:")&&(cin>>hourlyrate)))))))))){
            counter=counter+1; 
             calculategrosspay();
                calculatetax();
                calculatenetpay();
                printdata();
            printreport();
            
            
            
            }
            
            }
            
       payroll::payroll(){
     fin.open("payroll.txt",ios::out | ios::app | ios::ate);}
     payroll::~payroll(){   
     fin.close();
     }
       
        void payroll::printreport(){
            
            printheadings();
            printdata();
            fin<< employeename<<*(char*)&employeeid<<*(char*)&maritalstatus<<*(int*)&hoursworked<<*(float*)&hourlyrate;
               cin.get(); 
               
                
            }
            
            
                int main(){
                    payroll employee;
                    employee.start();
                    
                    
                    cin.get();
                 return 0;
                }

What's with all the

*(int*)&i

in your couts?

Without that code it still will give me memory addresses, and with it in my code it still gives me some type of a memory address.

Here is a version without the *(int *) &.
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116

    #include <iostream>
    #include <fstream>
    #include <iomanip>

    using namespace std;
    class payroll{
     ofstream fin;
     char employeeid[100][12];
     char employeename[100][100];
     char maritalstatus;
     int hoursworked, overtime;
     float hourlyrate,overtimepay,regularpay,grosspay,taxrate,taxamount,netpay;
     void calculategrosspay();
     void calculatetax();
     void calculatenetpay();
     void printheadings();
     void printdata();
     
     
     public:payroll();
     ~payroll();
     void printreport();
     void start(); };
     
     void payroll::calculategrosspay(){
            if(hoursworked > 40){
            overtime = hoursworked - 40;
            regularpay = hoursworked * hourlyrate;
            overtimepay = overtime*(hourlyrate * 1.5);
            grosspay = regularpay + overtimepay; }
            else grosspay = hoursworked * hourlyrate; }
     void payroll::calculatetax(){
            if(grosspay >=500) taxrate = .30;
            else if(grosspay > 200.00) taxrate = .20;
            else taxrate =.10;
            if(maritalstatus == 'S'||maritalstatus =='s')
            taxrate = taxrate +.05;
            taxamount = grosspay*taxrate;}
     void payroll::calculatenetpay(){
     netpay = grosspay - taxamount; }
     void payroll::printheadings(){
            cout<<setw(45)<<"-Payroll Report-"<<endl;
            cout<<"--------------------------------------------------"<<endl;
            cout<<"Name     ID   HW OT RT-PAY OT-PAY GROSS"
            "Tax  Netpay"<<endl;
            cout<<"--------------------------------------------------"<<endl;
        }
        void payroll::printdata(){
        cout<<setprecision(2)<<setiosflags(ios::showpoint);
        cout<<setw(6)<<employeename<<setw(12)<<employeeid<<setw(4)
        <<hoursworked<<setw(3)<<overtime<<setw(8)<<regularpay<<setw(8)
        <<overtimepay<<setw(8)<<grosspay<<setw(8)<<taxamount<<setw(8)
        <<netpay<<endl;

           
        }          
       void payroll::start(){
            int counter=0;
            int NumberOfEmp;
            cout<<"Enter the number of Employees"; 
            cin>>NumberOfEmp;  
            while(counter<NumberOfEmp) {
            cout<<"Employee ID:";
            cin>>employeeid[counter];
            cout<<"Enter the Employee Marital Status: Entet S for single or M for Married ";
            cin>>maritalstatus;
            cout<<"Enter in Employee Full name:";
            cin>>employeename[counter];
            cout<<"Enter Hours worked:";
            cin>>hoursworked;
            cout<<"Enter in hourly rate:";
            cin>>hourlyrate;
           
                     
            
            counter=counter+1; 
             calculategrosspay();
                calculatetax();
                calculatenetpay();
                printdata();
            printreport();
            
            
            
            }
            
            }
            
       payroll::payroll(){
     fin.open("payroll.txt",ios::out | ios::app | ios::ate);}
     payroll::~payroll(){   
     fin.close();
     }
        void payroll::printreport(){

        printheadings();
            printdata();
            fin<< employeename<<employeeid<<maritalstatus<<hoursworked<<hourlyrate;
               cin.get(); 

               
                
            }
            
            
                int main(){
                    payroll employee;
                    employee.start();
                    
                    
                    cin.get();
                 return 0;
                }

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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <iostream>
#include <fstream>
#include <iomanip>
using namespace std;

class payroll{
  public:
    ofstream fin;
    int counter;
    char employeeid[100][12];
    char employeename[100][100];
    char maritalstatus;
    int hoursworked, overtime;
    float hourlyrate,overtimepay,regularpay,grosspay,taxrate,taxamount,netpay;

    payroll();
    ~payroll();

    void calculategrosspay();
    void calculatetax();
    void calculatenetpay();
    void printheadings();
    void printdata();
    void printreport();
    void start();
};

    void payroll::calculategrosspay() {
        if(hoursworked > 40){
        overtime = hoursworked - 40;
        regularpay = hoursworked * hourlyrate;
        overtimepay = overtime*(hourlyrate * 1.5);
        grosspay = regularpay + overtimepay; }
        else grosspay = hoursworked * hourlyrate;
    }

    void payroll::calculatetax() {
        if(grosspay >=500) taxrate = .30;
        else if(grosspay > 200.00) taxrate = .20;
        else taxrate =.10;
        if(maritalstatus == 'S'||maritalstatus =='s')
        taxrate = taxrate +.05;
        taxamount = grosspay*taxrate;
    }

    void payroll::calculatenetpay() {
        netpay = grosspay - taxamount;
    }

    void payroll::printheadings() {
        cout<<setw(45)<<"-Payroll Report-"<<endl;
        cout<<"--------------------------------------------------"<<endl;
        cout<<"Name     ID   HW OT RT-PAY OT-PAY GROSS"
        "Tax  Netpay"<<endl;
        cout<<"--------------------------------------------------"<<endl;
    }

    void payroll::printdata() {
        cout<<fixed<<setprecision(2)<<setiosflags(ios::showpoint);//here
        cout<<setw(6)<<employeename[counter]<<setw(12)<<employeeid[counter]<<setw(4)//here
        <<hoursworked<<setw(3)<<overtime<<setw(8)<<regularpay<<setw(8)
        <<overtimepay<<setw(8)<<grosspay<<setw(8)<<taxamount<<setw(8)
        <<netpay<<endl;
    }

    void payroll::start() {
        counter = 0;
        int NumberOfEmp;
        cout<<"Enter the number of Employees";
        cin>>NumberOfEmp;
        while(counter<NumberOfEmp) {
            cout<<"Employee ID:";
            cin>>employeeid[counter];
            cout<<"Enter the Employee Marital Status: Entet S for single or M for Married ";
            cin>>maritalstatus;
            cout<<"Enter in Employee Full name:";
            cin>>employeename[counter];
            cout<<"Enter Hours worked:";
            cin>>hoursworked;
            cout<<"Enter in hourly rate:";
            cin>>hourlyrate;

            calculategrosspay();
            calculatetax();
            calculatenetpay();
            printdata();
            printreport();
            counter=counter+1;
        }
    }

    payroll::payroll() {
        fin.open("payroll.txt", ios::out|ios::app);//here
    }

    payroll::~payroll() {
        fin.close();
    }

    void payroll::printreport() {
        printheadings();
        printdata();
        fin << employeename[counter] << employeeid[counter] << maritalstatus//here
        <<hoursworked<<hourlyrate;
        cin.get();

    }

    int main() {
        payroll employee;
        employee.start();
        cin.get();
        return 0;
    }

i have tweak it a little, and mark it where i did it..
THANK YOU!!! I see what you did and It works!
i'm glad it help..
Topic archived. No new replies allowed.