program of employee class

Hi,
What's the problem of my program?
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
117
118
119
120
#include <iostream>
#include <string>
using namespace std;

const int n=10;
class employee
{

int a;
int h;
int n;
int e;
int m;
int h_total;
string f;
string l;
public:
void employeeID();
void first();
void last();
void base_salary();
double  wages_per_hour();
void print_wages_per_hour();
void overtime_hrs();
void  TAX_rate();
int total_wage();
void print_total_wage();
friend void sort(employee myemployee[],int n);
};
void employee :: employeeID()
{
cout<<"Enter ID Number:";
cin>>a;
}
void employee::first()
{
cout<<"Enter First Name:";
cin>>f;
}
void employee ::last()
{
	cout<<"Enter Last Name:";
	cin>>l;
}
void employee :: base_salary()
{
	cout<<"Enter Base Salary:";
	cin>>h;
}
double employee :: wages_per_hour()
{
	return n=(h/26)/8;
}
void employee :: print_wages_per_hour()
{
	cout<<"Enter Your Wages Per Hour"<<n<<endl;
}
void employee :: overtime_hrs()
{
	cout<<"Overtime Hrs:";
	cin>>e;
}
void employee :: TAX_rate()
{
	cout<<"Enter TAX_rate()
	cin>>m;
}
int employee :: total_wage()
{
	return h_total=(h + (e*n)) - (h*m)/100 ;
}
void employee :: print_total_wage()
{
	cout<<"Total Wages"<endl;
}
int main()
{

employee myemployee[n];
for (int i=0; i<n; i++)
{
cout<<"Employee" <<i+1<<":"<<endl;
myemployee[i].first();
myemployee[i].last();
myemployee[i].employeeID();
myemployee[i].base_salary();
myemployee[i].wages_per_hour();
myemployee[i].print_wages_per_hour();
myemployee[i].overtime_hrs();
myemployee[i].TAX_rate();
myemployee[i].total_wage();
myemployee[i].print_total_wage();

}

sort(myemployee[], int n);

cin.get();
cin.get();
}
void sort(employee myemployee[],int n)
{
	int hold;
	for (int i=0;i<n;i++)
	{
	for (int i=0;i<n-1;i++)
	{
		if (myemployee[i].h_total>myemployee[i+1].h_total)
		{
			myemployee[i].h_total=hold;
		myemployee[i].h_total=myemployee[i+1].h_total;
		myemployee[i+1].h_total=hold;
		}
	}
	}
	for (int i=0;i<n;i++)
	{
		cout<<myemployee[i].h_total<<endl;
	}
} 
Last edited on
Line 65 is missing a "
Check out the color of the text. That's your first hint. You're missing a quote in line 65.

Second, you're missing a semi-colon in line 65.

Third, you're missing a < in line 74 (should be <<endl; not <endl;)

Fourth, remove [] from myemployee in line 96.

Fifth, remove int from n in line 96.

That fixes the compiler errors. Your compiler would tell you the same thing in the output if you had looked at that.
Last edited on
Also on line 65 you have written cout<<"Enter TAX_rate() . Corrected as per the above posts that would leave cout<<"Enter TAX_rate()"; Since you are writing this to your user there is no need to display the name of the function. cout<<"Enter tax rate:"; would probably leave the user less confused.
Errors fixed but It has a bug in line 110 .when first wage Is larger than second wage It tells "uninitialized local variable 'hold' used " and doesn't give any sort.
See that variable hold? It doesn't have a value set. It could be anything. It could be zero. It could be a million. It could be minus ten. You're using it without ever having given it a value.
Thank you for answers .It fixed
Topic archived. No new replies allowed.