Help Payroll C++ for intro to C++ class

So, Ive been reading on this topic and it seems to have been mentioned before but I am still having errors appear with my program. The assignment is:

Write a program that uses the following arrays:
• empId: an array of seven long integers to hold employee identification numbers.
The array should be initialized with the following numbers:
5658845 4520125 7895122 8777541
8451277 1302850 7580489
• hours: an array of seven integers to hold the number of hours worked by each
employee
• payRate: an array of seven doubles to hold each employee’s hourly pay rate
• wages: an array of seven doubles to hold each employee’s gross wages
The program should relate the data in each array through the subscripts. For example, the number in element 0 of the hours array should be the number of hours
worked by the employee whose identification number is stored in element 0 of the
empId array. That same employee’s pay rate should be stored in element 0 of the
payRate array.
The program should display each employee number and ask the user to enter that
employee’s hours and pay rate. It should then calculate the gross wages for that
employee (hours times pay rate) and store them in the wages array. After the data has been entered for all the employees, the program should display each employee’s identification number and gross wages.
Input Validation: Do not accept negative values for hours or numbers less than 6.00
for pay rate.


Gaddis, Tony (2011-09-15). Starting Out with C++: From Control Structures through Objects, Brief Edition (7th Edition) (Page 445). Addison-Wesley. Kindle Edition.

My code is as follows, and it seems like an easy fix however I am getting an error at line 63 stating "expecting '}' At the end of input", but there is a bracket there. Is there something that I am missing?
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
 #include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
using namespace std;


int main() 
{

    const int empId = 7; 
	int workers[empId] = {5658846, 4520125, 7895122,
						  8777541, 8451277, 1302850,
						  7580489}; 
        int hours[empId]; 
    double payRate[empId];

    \
    cout << "Please enter the hours worked by " << empId
	 << " employees and their\n"
	 << "hourly pay rates.\n";
  for (int index = 0; index < empId; index++)
{
	cout << "Please enter the hours worked by employee number " << (index+1) << " (ID = " << workers[index] << ") : ";
	cin >> hours[index];
	cout << "Please enter the pay rate for employee number "<< (index+1) << " (ID = " << workers[index] << ") : ";
	cin >> payRate[index];

  do
	{
		cout << "Please enter the hours worked by employee number " << (index+1) << " (ID = " << workers[index] << ") : ";
		cin >> hours[index];

		if(hours[index] < 0)
		{
			cout << "Enter in a positive number" << endl; 
		}
	}
	while(hours[index] < 0); 
	
	do
	{
		cout << "Please enter the pay rate for employee number "<< (index+1) << " (ID = " << workers[index] << ") : ";
		cin >> payRate[index];

		if(payRate[index] < 6)
		{
			cout << "The pay rate must be >= 6" << endl; 
		}
	}
	while(hours[index] < 6);

    cout << "This is the gross pay for each employee:\n";
         cout << fixed << showpoint << setprecision(2);

  for (int index = 0; index < empId; index++)
{
	double grossPay = hours[index] * payRate[index];
	cout << "Employee #" << (index + 1);
	cout << ": earned $" << grossPay << endl << endl;
{
  return 0;
}
easy fix look at line 61 it is a { instead of } =p

*edit might I suggest a structure also even if it farther ahead http://www.cplusplus.com/doc/tutorial/structures/
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
struct Info
{
    int id;
    double hours , rate;
}

int main()
{
    int employees( 0 ) , id( 0 );
    double hours( 0 ) , rate( 0 );
    std::cout << "How many employees?\n> " << std::flush;
    std::cin >> employees;
    std::vector<Info> inf( employees );
    for( int i = 0; i < employees; ++i )
    {
        std::cout << "Please enter employee " << i + 1 <<  "\'s ID\n> " << std::flush;
        std::cin >> inf[ i ].id;
        std::cout << "Please enter employee " << i + 1 << "\'s hours\n> " << std::flush;
        std::cin >> inf[ i ].hours;
        std::cout << "Please enter employee " << i + 1 << "\'s rate\n> " << std::flush;
        std::cin >> inf[  i ].rate;
}


**Might be a few errors I haven't tested but it should work.
Last edited on
Yes, I thought about this. However, because this is an introduction class I wouldnt want to put any information into the program we have not yet learned about, as to avoid issues with the professor. Also I am still getting the error even after changing that at line 61.
lines 23 or 9 is also missing a closing bracket. If you use proper indentation
1
2
3
4
5
6
7
8
9
10
int main()
{
    loop()
    {
        if()
        {
            //stuff
        }
    }
}


It is much easier to tell if you are missing a bracket and which one
thanks so much, I am sorry I am new to all of this but I understand what you mean by proper indentation.
You can also try this:
Put "}" at line 55
Reverse "{" to "}" at line 61

That should allow your program to run and then you can begin debugging.

I'll also inquire about lines 29 to 54. I'm not quite clear of its purpose. Based on your description of the program these lines don't appear to be needed but I could me missing something in the logic.
Topic archived. No new replies allowed.