arrays and functions

Im almost done with this project, but when I out put the solution for the employees's wages I get really long negative numbers

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
//Cedric Shumate
//Payroll Wages Project

#include<iostream>
 #include<iomanip>
 using namespace std;

void getInfo();
void showInfo();

 int main()
 {
	
	getInfo();
	showInfo();
		



			 
	system("pause");
	return 0;
 }

 void getInfo()
 {
	  int count,
	 
	 empId[7] = {565, 452, 789, 877, 845, 130, 758};
	 double payRate;
	 double hoursWorked;
	 double wagesEarned[7];

		for(count = 0;count <= 6; count++)
		{
			 cout << "Employee number : " << empId[count] << endl;
	
			 cout << "\nEnter employee's hour : ";
			 cin >> hoursWorked;

		
			 cout << "Enter employee's pay rate : ";
			 cin >> payRate;

				wagesEarned[count] = hoursWorked * payRate;
			 cout << "\n";
		 }
 }


 void showInfo()
 {
	int count,
	 empId[7] = {565, 452, 789, 877, 845, 130, 758};
	double wagesEarned[7];
			 for(count = 0;count <= 6;count++)
				{
					cout << "Employee number : " << empId[count] << endl;
					cout << "Employee gross wager : " << fixed << setprecision(2) << wagesEarned[count] << endl;
					cout << "\n";
				}	
 }
Here

1
2
3
4
5
void showInfo()
 {
	int count,
	 empId[7] = {565, 452, 789, 877, 845, 130, 758};
	double wagesEarned[7];


local array wagesEarned is not initialized and contains arbitrary values.

I think you meant

1
2
3
4
5
6
7
8
9
void getInfo( double *, size_t  );
void showInfo( double *, size_t );

 int main()
 {
	const size_t N = 7;
	double wagesEarned[N];
	getInfo( wagesEarned[], N );
	showInfo( wagesEarned[], N );


now its asking for something in between the braces
[code]
getInfo( wagesEarned[], N );
showInfo( wagesEarned[], N );
[code]
It is your task to write bodies of the fwo functions. I showed you the right path.
Topic archived. No new replies allowed.